Ring Ring - 9 months ago 30
C++ Question

How do you call the copy constructor within a member function of a class?

Here's what I've got:

void set::operator =(const set& source)
if (&source == this)



And here's the error I get:

vset.cxx:33: error: declaration of 'source' shadows a parameter

How do I properly do this?


I believe with set(source); you are trying to call copy ctor. You can not do that in C++ i.e. you can not explicitly invoke the ctor. What you can do is write a private clone method and call it in both copy ctor and assignment operator.