You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
524 B
C++

// Start the program
// Create the class and declare the data members and member functions
// Declare the pointer and store the address of data in the pointer
// Create the object and call the function in the main program
// Compile and execute the program
#include<iostream.h>
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;
}