并得到这个错误,
这是我的代码:
class A { public: A(int a,int b,int c);};#include "A.h"................std::vector<A>* vec_objects = new std::vector<A>();while(....some condition ...) { A a(1,2,3) vec_objects->push_back(a);}
收到此错误:
c:\program files\microsoft visual studio 9.0\vc\include\xutility(3159) : error C2582: 'operator =' function is unavailable in 'A'1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(3187) : see reference to function template instantiation 'voID std::_Fill<A*,_Ty>(_FwdIt,_FwdIt,const _Ty &)' being compiled1> with1> [1> _Ty=A,1> _FwdIt=A *1> ]1> c:\program files\microsoft visual studio 9.0\vc\include\vector(1231) : see reference to function template instantiation 'voID std::fill<A*,1> _FwdIt=A *1> ]1> c:\program files\microsoft visual studio 9.0\vc\include\vector(1153) : while compiling class template member function 'voID std::vector<_Ty>::_Insert_n(std::_Vector_const_iterator<_Ty,_Alloc>,unsigned int,const _Ty &)'1> with1> [1> _Ty=A,1> _Alloc=std::allocator<A>1> ]1>
我做错了什么?
解决方法 您需要将operator =和copy-constructor添加到A类class A { public: A(int a,int c); A(const A& element); A& operator=(const A& element); //which needs deFinition};总结
以上是内存溢出为你收集整理的c – std :: vector error C2582:’operator =’函数不可用全部内容,希望文章能够帮你解决c – std :: vector error C2582:’operator =’函数不可用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)