Alex Rivera | Logout

How to use both default and custom copy constructor in C++?

Asked 2012-09-14T10:52:53.727
14

I have a long class with a lot of data members. I want to write a copy constructor for it. But, if I write my own copy constructor, I lose access to the default copy constructor.

I just want to repair a few pointers in my own copy constructor. So I want to have a shallow copy of the object which can be done by the default copy constructor.

Is there a possibility to access the default copy constructor when I have my own copy constructor?

Edit
Report

1 Answer

0

You can either use the default or your own, not both. If you want to choose different functionality for different objects you should just write a member function that handles that case.

void DeepCopy(MyClass* rhs);

For example.

answered 2012-09-14T11:00:02.410

Your Answer