- 论坛徽章:
- 0
|
#include <vector>
#include <iostream>
using namespace std;
class A
{
private:
int x;
public:
A(int p){x=p;}
A(){x=0;}
int get(){return x; }
//~A(){}
A(A & a){x=a.x;}
};
int main()
{
vector<A> p(5,5);
for(int i=0;i<5;i++)
cout<<p[i].get()<<endl;
return 0;
}
我的编译器为vc6.0,错误提示如下:
error C2558: class 'A' : no copy constructor available
c:\program files\microsoft visual studio\vc98\include\xmemory(66) : see reference to function template instantiation 'void __cdecl std::_Construct(class A *,const class A &)' being compiled
Error executing cl.exe.
过后我也看了memory头文件,但并未理解其中含义
另外,在使用map(等模板)时,如果用string实例化会出现大量警告
希望各位高手,莫笑我问得肤浅,能指点一二
谢谢! |
|