#include<iostream>
using namespace std;
class item
{
int itemno;
int itemprice;
public :
static int total;
void getprice();
void printprice();
friend void calculate(item a);
};
int item :: total=0;
void item :: getprice()
{
cout<<"Print item number \n";
cin>>itemno;
cout<<"Print item price \n";
cin>>itemprice;
total++;
}
void item :: printprice()
{
cout<<"item "<<itemno<<" itemprice "<<itemprice<<endl;
cout<<total<<"\n";
}
void calculate(item a)
{
total+=a.itemprice;
}
int main()
{
item array[5];
int i;
for(i=0;i<2;i++)
{
array[i].getprice();
calculate(array[i]);
}
for(i=0;i<2;i++)
{
array[i].printprice();
}
}
see the above programme show error cos i cannot use static variable total in friend function properly........ how can i do this