Search This Blog

Friday, 26 October 2012

Returning values form member functions

#include<iostream.h>
class item{
private:
int itemno,price;
public:
void getItemDetails(int I,int j)
{
itemno=I;
price=j;
}
int cal_amount(int q)
{
return q*price;
}
void printdetails()
{
cout<<itemno<<price;
}
};
void main()
{
item K;
K.getItemDetails(3,45);
int r=K.cal_amount(5);
cout<<"Amount="<<r;
}

Output:
Amount=225

No comments:

Post a Comment