#include // assert #include // cout, endl #include // vector #include struct A { const int i; A (int i) : i (i) {} A operator = (A other){ A temp = A(other); return temp; } /* A& operator = (A other){ A temp = A(other); //std::cout << "temp = " << temp << std::endl; std::swap(*this, temp); return *this; } */ friend std::ostream& operator << (std::ostream& lhs, const A& rhs) { lhs << rhs.i; return lhs; } }; int main () { using namespace std; A x(2); A w(3); vector y(10, x); vector z(5,w); z[2]=y[4]; //z.push_back(y[1]); for(size_t i = 0; i < 10; ++i) { cout << y[i] << " "; } cout << endl; for(size_t i = 0; i < 5; ++i) { cout << z[i] << " "; } cout << endl; cout << "Done." << endl; }