class MyClass{
public:
MyClass();
MyClass(const MyClass& my);
MyClass(MyClass&& my);
};
void func(MyClass my);
int main()
{
func(MyClass());
MyClass myClass(MyClass());
return 0;
}
func(MyClass())
runs fine. And here, MyClass()
is an anonymous instance. But MyClass myClass(MyClass())
is a function, not an object. And here, MyClass()
is a pointer to function. I think it should call the copy constructor but it doesn't. why?
*note : I know myClass
is a function if it has empty parentheses.