Don't quite understand why this copy constructor is not invoked when I build with debug mode using VC2010.
class SomeClass
{
public:
SomeClass(int meaningless){}
SomeClass(const SomeClass& sc)
{
cout << "Copy Constructor invoked!" << endl;
}
};
int main()
{
SomeClass test(SomeClass(9999)); // Copy constructor not invoked.
}
I think this has nothing to do with RVO since I am not returning any values.
More interesting, when I make the copy constructor private, the compiler wouldn't even compile even if it omit the copy constructor.
See Question&Answers more detail:os