c++ STL vector is not acccepting the copy constructor
- by prabhakaran
I wrote a code ( c++,visual studio 2010) which is having a vector, even I though copy const is declared, but is still showing that copy const is not declared
Here the code
#include<iostream>
#include<vector>
using namespace std;
class A
{
public:
A(){cout << "Default A is acting" << endl ;}
A(A &a){cout << "Copy Constructor of A is acting" << endl ;}
};
int main()
{
A a;
A b=a;
vector<A> nothing;
nothing.push_back(a);
int n;
cin >> n;
}
The error I got is
Error 1 error C2558: class 'A' : no copy constructor available or copy constructor is declared 'explicit' c:\program files\microsoft visual studio 10.0\vc\include\xmemory 48 1 delete
Anybody please help me