[求助]error C2065: 'total' : undeclared identifier
//一个描述商品销售的例子#include "iostream.h"
class sale
{private:
float price;
char number;
char saleornot;
public:
void get(float p,int n,char s);
float total();
int sore();
};
//用关键字inline实现一个内联标记的作用
//inline就是告诉编译器内联编译的开始
inline void sale::get(float p,int n,char s)
{price=p;
number=n;
saleornot=s;
}
inline float sale::total()
{float t;
t=price*number;
return t;
}
inline int sale::sore()
{if(saleornot=='y')
return 1;
else return 0;
}
void main()
{sale goods1,goods2;
goods1.get(28.5,200,'y');
goods2.get(30,300,'n');
if(goods1.sore()==1)
{cout<<"the total sale amount of goods1 is :"<<"$"<<total()<<endl;}
else cout<<"the goods1 have not been sold!";
cout<<"\n";
if(goods2.sore()==1)
{cout<<"the total sale amount of goods2 is:"<<total()<<endl;}
else cout<<"the goods2 have not been sold!";}