Hi,
Please tell me in the following question why no copy constructor is called when fun returns the A object.
While returning b and constructing c, there is no copy constructor called. Why??
#include<iostream>
using namespace std;
class A
{
public:
A(){cout <<"Default\n";}
A(const A&){
cout<<"copy\n";
}
A fun(A a)
{
A b;
return b;
}
};
int main()
{
A a;
A c = a.fun(a); // Here atleast copy copy constructor should have been called.
return 0;
}