Class and Object

#include <iostream.h>
#include <conio.h>
class Data
{
private :
int num;
public :
void getNumber(int n)
{
num = n;
}
void showNumber( )
{
Cout<<”Num = “<<num<<”\n”;
}
};
void main( )
{
Data d1;
d1.getNumber(10);
d1.showNumber( );
}
Output :
Num = 10

0 comments: