I was expecting it should call either copy or move constructor but neither of them called.
#include <iostream>
using namespace std;
class A
{
public:
A()
{
std::cout << "A" << std::endl;
}
A(A &)
{
std::cout << "C" << std::endl;
}
A(A &&obj)
{
std::cout << "M" << std::endl;
}
};
A get()
{
A obj;
return obj;
}
int main()
{
A obj = get();
return 0;
}
Output
A