So here is the code snippet:
class MyClass { public: MyClass(char chIn) { std::cout << "Constructor!" << std::endl; }
MyClass & operator= (char chIn) { std::cout << "Assigment operator!" << std::endl; } } ;
void Func(MyClass objIn) { return; }
int _tmain(int argc, _TCHAR* argv[]) { Func('T'); system("PAUSE"); return 0; }
In the upper example the constructor of the object is called!!!! Why is this behavior? Shouldn't the assigment operator be called? Because we're assigning a value to the function parameter, aren't we?