Given class:
class C
{
public:
C()
{
cout << "Dflt ctor.";
}
C(C& obj)
{
cout << "Copy ctor.";
}
C(C&& obj)
{
cout << "Move ctor.";
}
C& operator=(C& obj)
{
cout << "operator=";
return obj;
}
C& operator=(C&& obj)
{
cout << "Move operator=";
return obj;
}
};
and then in main:
int _tmain(int argc, _TCHAR* argv[])
{
C c;
C d = c;
C e;
e = c;
return 0;
}
as you will see from the output there are "regular" ver. of cpy ctor and = optor invoked but not those with rvalue args. So I would like to ask in what circumstances move ctor and operator=(C&&) will be invoked?
Thank you.