开发者

A Polymorphism Problem

开发者 https://www.devze.com 2022-12-09 00:27 出处:网络
it works when : list<ItemFixed> XYZ::List() { list<Ite开发者_开发问答m> items = _Browser->GetMusic();

it works when :

list<ItemFixed> XYZ::List()
{
        list<Ite开发者_开发问答m> items = _Browser->GetMusic();
        list<ItemFixed> retItems = _Converter->Convert (items);
        return retItems;
}

but not :

list<ItemFixed> XYZ::List()
{
        return _Converter->Convert (_Browser->GetMusic());
}

Any suggestions? thanks


Are you passing the list<Item> as non-const reference to Convert function? In that case it will not compile as you can not pass temporary object by non-const reference in C++.

0

精彩评论

暂无评论...
验证码 换一张
取 消