© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

Home Lab Exercise Object Oriented Programming Lab Exercise ProgramsCPP Program For Declaring Pointers as Class Member▼


CPP Program For Declaring Pointers as Class Member

Alogarithm steps:

  1. Start the program
  2. Create the class and declare the data members and member functions
  3. Declare the pointer and store the address of data in the pointer
  4. Create the object and call the function in the main program
  5. Compile and execute the program

CPP Program For Declaring Pointers as Class Member

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

SAMPLE INPUT AND OUTPUT:

1

 
SLogix Student Projects

⇓Student Projects⇓
⇑Student Projects⇑
bottom