class CheckoutRecord{
public:
friend ostream& operator<< (ostream& out,const CheckoutRecord& cr);
void test() {}
private:
double book_id;
string title;
Date date_borrowed;
Date date_due;
pair<string,string> borrower;
//vector< pair<string,string> * > wait_list;
};
ostream& operator<< (ostream& out,const CheckoutRecord& cr){
//out<<cr.book_id<<"/t"<<cr.title<<"/t"<<cr.date_borrowed.getDay();
cr.test();
return out;
}
今天写C++ Primer课后习题的时候发现一个错误,于是自己测试了下
报错 passing 'const CheckoutRecord' as 'this' argument of 'CheckoutRecord' discards qualifiers
原来出错的原因是const对象不能调用非const函数