As per my understanding, the move constructor will be called when there is a temporary object created. Here the getA() function is returning a temporary object but my program is not printing the message from the move constructor:
#include <iostream> using namespace std; class A { public: A() { cout<<"Hi from default\n"; } A(A && obj) { cout<<"Hi from move\n"; } }; A getA() { A obj; cout<<"from getA\n"; return obj; } int main() { A b(getA()); return 0; }