![]() |
#2
rjsp2016-03-24 09:29
|

std::ostream& operator<<(std::ostream& os, const Student& stu)//只要将&去掉,下面的代码就能正常跑,可是会创建临时变量,想做成直接引用的....
{
using std::setw;
using std::setfill;
os << setw(stringWeith) << setfill(' ') << stu.name//报错成员name不可访问
<< setw(numberWeith) << setfill(' ') << stu.ID
<< setw(charWeith) << setfill(' ') << stu.sex << std::endl;
return os;
}
{
using std::setw;
using std::setfill;
os << setw(stringWeith) << setfill(' ') << stu.name//报错成员name不可访问
<< setw(numberWeith) << setfill(' ') << stu.ID
<< setw(charWeith) << setfill(' ') << stu.sex << std::endl;
return os;
}