https://www.educative.io/edpresso/what-is-a-move-constructor-in-cpp
int main()
{
vector <A> vec;
vec.push_back(A());
return 0;
}
Now, when the above code is executed, the default constructor is called at the time that the temporary object A is created. The copy constructor is called as the temporary object of A is pushed back in the vector.
All I know is that copy constructor gets called like this:
classA obj1;
classA obj2 = obj1;
Why does copy constructor get called with this statement?
vec.push_back( A() );
Here all we are doing is calling the constructor with A()
and then the object will get stored in the vector.