Maybe I didn\'t make my question clear, the following answers are not answering my question. Let me make the question more specific. My question is that I have a base class to s
The way to go is to have an opaque pointer to the implementation.
class BaseImpl;
class Base {
public:
Base();
~Base();
private:
// virtual functions to be overridden by derived classes.
virtual void Initialize() {}
private:
// private members and functions that are not intended to override by derived classes
void Configure() { m_impl->Configure(); }
BaseImpl* m_impl;
}
Then, in the BaseImpl
, you keep a pointer to the Base
and you call the virtual functions as wanted. You keep BaseImpl.h
in your private includes and you don't distribute it to the library users.
See: https://en.cppreference.com/w/cpp/language/pimpl