I know many examples are on stackoverflow regarding copy constructors. However, I have not seen one with my specific problem.
Suppose I have a base class Base
that is defined like this:
class Base
{
public:
Base(const Base &other);
...
}
and that I have a derived class Derived
that is defined like this:
class Derived
{
public:
Derived(const Base &other); //construct from base class
Derived(const Derived &other); //construct from derived class (copy constructor)
}
Can the copy constructor be defined like this?
Derived::Derived(const Derived &other) : Base(other) {...}
Or is this not good style in C++? If not, how can I get the same result using a better method? My compiler (MSVC) doesn't seem to complain about it.