G++ compiler error - Synthesized method first required here

◇◆丶佛笑我妖孽 提交于 2019-12-05 05:14:52

The problem is that you cannot return a plain ostream. You have to return a reference to the one you received as argument (note the &).

ostream & operator <<(ostream &out, const Date &date)

The compiler complains that it cannot create a new ostream object by copying out on the line return out;.

The error is most likely here:

ostream operator <<(ostream &out, const Date &date)

The function should return the stream as a reference, just like it receives it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!