Search This Blog

Friday, 26 October 2012

Pointers to Objects

#include<iostream.h>
class A{
private:
int a;
public:
void getdata()
{
cout<<"Get Number";
cin>>a
}
void display()
{
cout<<"Data="<<a;
}
};
void main()
{
A a,*b;
b=&a;
a.getdata();
a.display();
b->getdata();
b->display();
}
 

No comments:

Post a Comment