错在哪里?谢谢
#ifndef B#define B
#include<iostream>
#include<string>
class b{
public:
std::istream& input(std::istream& in);
std::ostream& output(std::ostream& out) const;
double a() const;
bool isbn(const b &rhs) const
{
return isbn==rhs.isbn;
}
private:
std::string isbn;
unsigned units_sold;
double revenue;
};
#endif
std::istream& b::input(std::istream& in)
{
double price;
in>>isbn>>units_sold>>price;
if(in)
revenue=units_sold*price;
else{
units_sold=0;
revenue=0.0;
}
return in;
}
std::ostream& b::output(std::ostream& out) const
{
out<<isbn<<"\t"<units_sold<<"\t"<<revenue<<"\t"<<a();
return out;
}
double b::a() const
{
if(units_sold)
return revenue/units_sold;
else
return 0;
}
#include<iostream>
using namespace std;
int main()
{
b item;
cout<<"Enter"<<endl;
while(item.input(cin))
{
cout<<item.output(cout);
cout<<endl;
}
return 0;
}
请问错在哪里,还有,高手可以解释一下类定义中代码的意思吗,我不太明白,谢谢