#include<iostream.h>
#include<conio.h>
class example
{
private :
int i;
public :
void setdata(int ii)
{
i = ii; //one way to set data
cout<<endl<<" My object's address is "<<this << endl;
this->i=ii; // another way to set data
}
void showdata( )
{
cout<<i; // one way to display data
cout<<endl<<" My object's address is "<<this<< endl;
cout<<this->i; //another way to display data
}
};
void main( )
{
example e1;
e1.setdata(10);
e1.showdata( );
getch( );
}
0 comments:
Post a Comment