assign the address of a public member of an object to a pointer and then access that member by using the pointer : object pointer « Pointer « C++ Tutorial






#include <iostream>
using namespace std;
   
class cl {
public:
  int i;
  cl(int j) { i=j; }
};
   
int main()
{
  cl ob(1);
  int *p;
   
  p = &ob.i; // get address of ob.i
   
  cout << *p; // access ob.i via p
   
  return 0;
}








11.7.object pointer
11.7.1.Pointers to Objects
11.7.2.uses a pointer to access all three elements of array ob after being assigned ob's starting address
11.7.3.assign the address of a public member of an object to a pointer and then access that member by using the pointer
11.7.4.dereferencing the pointer returned by new
11.7.5.array of pointers to objects