在第一章敲到 #include "Sales_item.h"时,编译出现错误,原因是Sales_item类不是标准库自带的,需要自己写好再使用头文件(#include "Sales_item.h)访问,作者已经写好了这个类,名为Sales_item.h,如下:
#ifndef SALESITEM_H
#define SALESITEM_H
#include <iostream>
#include <string>
class Sales_item{
public:
Sales_item(const std::string &book):isbn(book),units_sold(0),revenue(0.0){}
Sales_item(std::istream &is){ is >> *this;}
friend std::istream& operator>>(std::istream &,Sales_item &);
friend std::ostream& operator<<(std::ostream &,const Sales_item &);
public:
Sales_item & operator+=(const Sales_item&);
public:
double avg_price() const;
bool same_isbn(const Sales_item &rhs)const{
return isbn == rhs.isbn;
}
Sales_item():units_sold(0),revenue(0.0){}
public:
std::string isbn;
unsigned units_sold;
double reve