If two classes have exactly same data members and member function and only they differ by class name. Can copy constructor be used to initialize one class object with another class object?
If two classes have exactly same data members and member function and only they differ by class name. Can copy constructor be used to initialize one class object with another class object? Correct Answer No, not possible
The restriction for copy constructor is that it must be used with the object of same class. Even if the classes are exactly same the constructor won’t be able to access all the members of another class. Hence we can’t use object of another class for initialization.
মোঃ আরিফুল ইসলাম
Feb 20, 2025