Assign the public object member address to a pointer
#include <iostream> using namespace std;
class MyClass {
public: int i;
MyClass(int j) {
i = j;
}
}; int main()
{
MyClass myObject(1); int *p;
p = &myObject.i; // get address of myObject.i
cout << *p; // access myObject.i via p return 0;
}