I am trying to understand when the move constructor is called, and wrote this simple piece of code:
class myClass
{
public:
myClass(int value)
{
cout << "This is my constructor" << endl;
}
myClass(const myClass& other)
{
cout << "This is my copy constructor" << endl;
}
myClass(myClass&& other)
{
cout << "This is my move constructor" << endl;
}
};
int main()
{
myClass a(myClass(3));
}
The output is:
This is my constructor
I understand the constructor is called for myClass(3). My question is, why isn't the move (or even copy) constructor called for moving the memory to 'a'?