习题7.31 定义Sales_item的读写两个成员函数
#include<string> using namespace std; class Sales_item { public: double avg_price() { return revenue/units_sold; } bool same_isbn(const Sales_item &rhs) { return this->isbn == rhs.isbn; } void getSalesItem() { cout<<this->isbn<<" "<<units_sold<<" "<<revenue<<endl; } void setSalesItem(string isbn,unsigned units_sold,double revenue) { this->isbn = isbn; this->units_sold = units_sold; this->revenue = revenue; } private: string isbn; unsigned units_sold; double revenue; };
posted on 2011-12-03 15:05 york_software123 阅读(112) 评论(0) 收藏 举报