class Sample
{
public:
Sample(){}
Sample(const Sample& obj){ cout<<"C.C. with 1 argument called"<<endl;}
Sample(const Sample& obj, int i){ cout<<"C.C. with 2 arguments called"<<endl;}
};
void main()
{
Sample s1;
Sample s2 = s1; // Here, C.C with 1 arg. called.
}
There are few questions:
- How I can make a call to copy constructor having 2 arguments?
- When we require a copy constructor with 1 argument and when we require C.C with 2 argument?
A constructor with 2 (or more) required arguments is not a copy constructor.
1.: