Search This Blog

Thursday, 25 October 2012

Passing arguments to member function

#include<iostream.h>
class item{
private:
int itemno,price;
public:
void getitemDetails(int I,int j)
{
itemno=I;
price=j;
}
void printdetails()
{
cout<<itemno<<price;
}
};
void main()
{
item k;
k.getItemDetails(3,45);
k.printdetails();
}

Output:
3 45

No comments:

Post a Comment