| re: map::insert gives compile error when copy constructor is added.
indushekara wrote:[color=blue]
> Hi,
> I want to know what is the problem with this code. I am trying to
> insert in a map<int,A> where in i have defined the copy constructor
> for A
> I get the following error in VS6.
> e:\program files\microsoft visual studio\vc98\include\utility(21) :
> error C2558: class 'A' : no copy constructor available
> e:\program files\microsoft visual
> studio\vc98\include\utility(21) : while compiling class-template
> member function '__thiscall std::pair<int const ,class
> A>::std::pair<int const ,class A>(const int &,const class A &)'
>
> #pragma warning(disable:4786)
> #include <map>
> using namespace std;
> class A{
> public:
> A::A(){};
> A::A(A& a){};[/color]
A(){}
A( const A& a ){} // canonical copy constructor
[color=blue]
> };
> int main()
> {
> map<int,A> mapA;
> A A1;
> mapA.insert(map<int,A>::value_type(1,A1));
> return 0;
> }[/color]
Jeff Flinn |