#include <iostream>
#include<string>
using namespace std;
class Person {
private:
public:
//传统初始化
string name;
int age;
int *height;
Person(string a, int b, int c) {
name = a;
age = b;
height =new int(c);
}
};
void test01() {
Person p("haha", 1, 2);
cout << p.age << endl;
cout << p.name << endl;
cout << p.height << endl;
}
int main() {
test01();
system("pause");
return 0;
}
cout << p.height << endl;这一句只能显示内存地址,如果我想显示他本身代表的值应该如何操作,请问?
我是C++初学者,p.*height,p->height,p->*height这些写法都报错,请问该如何解决,谢谢~~~