I had an inkling the following code wouldn't work before I compiled it but I was vindicated and I don't feel any good.
Well, the error message I get is the following:Code:class A { private: int i; public: A(){} A(A& a){i = a.get_i();} ~A(){} void set_i(int j){i = j;} int get_i(){return i;} }; int main() { A b; vector<A> bb; for(int i = 0; i < 10; i++) bb.push_back(b); bb[0].set_i(3); bb[1].set_i(4); ... }
Aren't vectors supposed to work with all sorts of classes and types?c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\vector(810): error C2558: class 'A' : no copy constructor available or copy constructor is declared 'explicit'
And how do you make a copy construtor that works with a vector?