Mega Code Archive

 
Categories / C++ / Pointer
 

Pointers to Objects

#include <iostream> using namespace std; class myclass {   int i; public:   myclass(int j) {       i = j;    }   int getInt() {       return i;    } }; int main() {   myclass ob(88), *objectPointer;   objectPointer = &ob;             // get address of ob   cout << objectPointer->getInt();  // use -> to call getInt()   return 0; }