#include
class item
{
float cost;
int number;
public:
void getdata(int,float);
void putdata()
{
cout<<"\nNumber="<< number<<"\n";
cout<<"Cost="<< cost<<"\n";
}
};
void item::getdata(int a,float b)
{
number=a;
cost=b;
}
void main()
{
clrscr();
item a;
a.getdata(100,20.31);
a.putdata();
item b;
b.getdata(180,25.56);
b.putdata();
getch();
}
Output will be:
Number=100
Cost=20.309999
Number=180
Cost=25.559999
No comments:
Post a Comment