I have a class which inherits from a base class which provides a protected constructor which is empty.
Is it necessary for me to implement the blank constructor (and destructor) in the derived class or will the compiler generate the appropriate one for me. I am using C++ 11.
While some aspacts of the questions are answered in this post (How is "=default" different from "{}" for default constructor and destructor?), I am mostly interested in the behaviour when the class is derived.
So I have something like:
template<typename EnumClass>
class IVCounter
{
protected:
//!
//! \brief Ensure that this base class is never instantiated
//! directly.
//!
IVCounter() {}
public:
//!
//! \brief Virtual destructor
//!
virtual ~IVCounter() {}
};
class Derived: public IVCounter<SomeType>
{
// Do I have to do this?
Derived()
: IVCounter()
{}
~Derived() {}
};
Or perhaps in the derived I can simply do:
Derived() = default;
~Derived() = default;
or maybe even leave it out altogether?