Would this constructor be acceptable practice?

Posted by Robb on Stack Overflow See other posts from Stack Overflow or by Robb
Published on 2010-04-30T16:39:29Z Indexed on 2010/04/30 16:47 UTC
Read the original article Hit count: 226

Filed under:
|
|
|

Let's assume I have a c++ class that have properly implemented a copy constructor and an overloaded = operator. By properly implemented I mean they are working and perform a deep copy:

Class1::Class1(const Class1 &class1)
{
  // Perform copy
}
Class1& Class1::operator=(const Class1 *class1)
{
  // perform copy
  return *this;
}

Now lets say I have this constructor as well:

Class1::Class1(Class1 *class1)
{
   *this = *class1;
}

My question is would the above constructor be acceptable practice? This is code that i've inherited and maintaining.

© Stack Overflow or respective owner

Related posts about c++

Related posts about oop