如何使用指向对象的指针打印指针 p 的值?
#include <iostream>
class Test {
public:
int a = 1;
int *p = &a;
};
int main(){
using namespace std;
Test* obj = new Test;
cout << obj->*p << endl;
return 0;
}
如何使用指向对象的指针打印指针 p 的值?
#include <iostream>
class Test {
public:
int a = 1;
int *p = &a;
};
int main(){
using namespace std;
Test* obj = new Test;
cout << obj->*p << endl;
return 0;
}
像这样的东西:
C风格:
要获取值(响应评论):