class Test
{
public:
Test(int i) { cout<<"constructor called\n";}
Test(const Test& t) { cout<<" copy constructor called\n";}
};
class Test1
{
public:
Test1(int i) { cout<<"constructor called\n";}
explicit Test1(const Test1& t) { cout<<" copy constructor called\n";}
};
int main()
{
Test t(0);
Test u = 0;
//Test1 t1(0); Line 1
//Test1 u1 = 0; Line 2
}
I observe different outputs. Case 1: When Line 1 and Line 2 are commented the o/p is : constructor called constructor called
Case 2: When Line 1 and Line 2 are uncommented : then compilation error
Can someone explain the outputs and the reason for that. Also can someone tell if operator= actually ends up calling the copy constructor or not.