首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

ubuntu eclipse c++ list有关问题

2013-01-21 
ubuntu eclipse c++ list问题编译环境eclipse c++class a{public:a& operator (a& i)}inline a& a::ope

ubuntu eclipse c++ list问题
编译环境eclipse c++
class a
{
public:a& operator =(a& i);
};
inline a& a::operator =(a& i)
{
printf("ddd");
return *this;
}

当如此使用时 list<a> a1,a2;  
           a1=a2;
报错:错误: ‘operator=’在__first1.std::_List_iterator<_Tp>::operator*<a>() = __first2.std::_List_const_iterator<_Tp>::operator*<a>()’中没有匹配

当注释掉a的赋值运算符时完全没有问题。
而且这个例子在vc也完全没有问题。
在ubuntu下 a a1,a2;  a1=a2; 也完全没有问题的。
所以只能求教高手来指点迷津了。
首先在此拜谢一下,急等啊!!!!

[解决办法]
list<a> 的赋值,自动调用的operator为

a& operator=(const a&)

而你定义了a& operator=(a&)

热点排行