[英]Attempting to put an overloaded cout function call within another cout overloaded function
我的代码中有两个对象。 一个在另一个中使用。 我正在尝试编写一个重载的 cout function,它将打印来自每个 class 的项目。 尝试运行我的程序时出现错误
error: invalid use of non-static data member 'Glip::brain'
outs << brain;
^~~~~
friend ostream &operator<<(ostream &outs, const Glip &glip){
outs << std::right << setw(10) << glip.name << "\n";
outs << "----------------- \n";
outs << "Height: " << right << setw(1) << glip.height << "\n";
outs << "Weight: " << setw(1) << glip.weight << "\n";
outs << "Color: " << setw(1) << glip.color << "\n";
if(glip.horn == true) {
outs << left << setw(4) << "Horn";
}
else
outs << setw(4) << "No Horn";
outs << brain;
return outs;
}
我究竟做错了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.