如何解决试图将重载的 cout 函数调用放入另一个 cout 重载的函数中
我的代码中有两个对象。一个在另一个中使用。我正在尝试编写一个重载的 cout 函数,它将打印每个类中的项目。尝试运行我的程序时出现错误
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;
}
我做错了什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。