C++: Why does my DerivedClass’s constructor not have access to the BaseClass’s protected field?

You cannot initialize m_data in the derived class constructor but instead pass it as an argument to the base class constructor.

That is: DerivedClass::DerivedClass(std::string data) : BaseClass(data) { }

Leave a Comment