Possible Duplicate:
Why copy constructor is not called in this case?
Considering the following code snippet:
#include <iostream>
using namespace std;
class Test
{
char name[16];
public:
Test ()
{
cout <<"Inside Constructor"<<endl;
}
Test (const Test & t)
{
cout <<"Inside Copy Constructor "<<endl;
}
};
Test f()
{
return Test();
}
int main ( int argc, char ** argv)
{
Test t;
Test t1 = f();
}
Test t1= f() -> it invokes f(), and which returns the Test object, and then as per my understanding the copy constructor should be invoked. But i get the following output:
Inside Constructor
Inside Constructor
what is wrong with my understanding?.