#ifndef SALESITEM_H
#define SALESITEM_H
#include <iostream>
#include <string>
using namespace std;
class Sales_data
{
public:
Sales_data(unsigned num,int pr , string isb):units_sold(num),price(pr),isbn(isb)
{
cout<<"it works"<<endl;
};
Sales_data() = default;
Sales_data& combine(const Sales_data& rhs);
string Getisbn() ;
int Getprice() ;
unsigned Getunits_sold();
private:
unsigned units_sold;
int price;
string isbn;
};
Sales_data& Sales_data::combine(const Sales_data& rhs)
{
units_sold += rhs.units_sold;
price += rhs.price;
return *this;
}
string Sales_data::Getisbn()
{
return isbn;
}
int Sales_data::Getprice()
{
return units_sold;
}
unsigned Sales_data::Getunits_sold()
{
return units_sold;
}
istream& read(istream& in,Sales_data &book)
{
in >>book.Getisbn();
return in;
}
그리고 그것은 로그잘못된 피연산자 :
에서>> book.Getunits_sold (에 그 문제를 나타냅니다) /Users/apple/Desktop/shirley/shirley/Sales_item.h:185 : 8 :이 있다고 왜 바이너리 표현 ('IStream을'(일명 'basic_istream보다는') 와 '캐릭터'(일명 'basic_string, 할당>'))에 잘못된 피연산자
귀하의 포함 사항을 볼 수 있도록 전체 예제를 게시하십시오. 나는'#include'이 그들 중 하나가 아니라고 추측 할 것이다. –
#include이 헤더에 있습니다. –
글쎄, 예제에는'>>'가 하나 있는데, 오른쪽에는 문자열이 없습니다. 당신의 예제에는 185 행도 없으므로, 나는 여러분이 보여주지 않은 코드에 오류가 있다고 말할 것입니다. 당신이'book.Getunits_sold();'에서 무엇을 생각할 지 모르겠습니다. –