Код:#include #include class A{ public: A(); A(A &a); int geta() const; private: int a_;};A::A():a_(1){}A::A(A &a):a_(a.geta()){ }int A::geta() const{ return a_;}void main(){ A a; std::vector vec; vec.insert(vec.end(), a);}Компилятор выдаёт:------ Build started: Project: test4, Configuration: Debug Win32 ------Compiling...main.cppd:\lang\microsoft visual studio 8\vc\include\vector(1125) : error C2558: class 'A' : no copy constructor available or copy constructor is declared 'explicit' d:\lang\microsoft visual studio 8\vc\include\vector(1117) : while compiling class template member function 'void std::vector::_Insert_n(std::_Vector_iter ator,__w64 unsigned int,const _Ty &)' with [ _Ty=A, _Alloc=std::allocator ] d:\lang\myprojects\c++\qt\test4\test4\ma in.cpp(36) : see reference to class template instantiation 'std::vector' being compiled with [ _Ty=A ]Build log was saved at "file://d:\Lang\MyProjects\C++\QT\test4\test4\De bug\BuildLog.htm"test4 - 1 error(s), 0 warning(s)
|