推荐我有以下类列出:添加操作符重载
class ListWrapper
{
private: vector<MyItem> items;
public : MyItem& operator+(MyItem& itm){items.push_back(itm);}
};
class MyItem
{
private: int data;
};
,才有可能增加项目使用运营商+运算符重载MYLIST?
I.e. :
MyItem item1,item2,item3;
ListWrapper lw;
lw + item1 + item2+ item3;
我可以在ListWrapper使用的运营商,但有一种方式,通过多个项目,像这样的例子有吗?
你_have_返回从你的'+'运算符的东西。它应该是一个'ListWrapper' –