I am not sure if this is what you are looking for or if this will help you in your case. I will however demonstrate polymorphic behavior.
Protected Constructor Abstract Class
class BaseProtected {
// ----- Member Variable Section -----
public:
// There Shouldn't Be Public Variables In A Base Class Unless
// That Is The Behavior You Are Looking For - Keep In Mind
// Every Inherited Class & Outside Class Can Change Them.
protected:
// Member Variables Here To Be Shared With Each Derived Class
private:
// Member Variables Here To Be Used By Base Class Only
// ----- Member Function Section -----
public:
virtual ~BaseProtected(); // Virtual Destructor
void somefunc() const; // Common Function Between All Derived Class
virtual void allDerivedMustImplement() const; = 0 // Purely Virtual
protected:
// Default Constructor - Can Not Declare An Instance Of Base Class
BaseProtected(); // Abstract Class
// Protected Functions Shared Between Classes
// Protected Functions That Are Purely Virtual If Needed
private:
// Private Functions Used By Base Class Only
}; // BaseProtected
Derived Class With Possible Inheritance
class DerivedWithPossibleInheritance : public BaseProtected {
// ----- Member Variable Section -----
public:
// Public Member If Giving Free Access
protected:
// Protected Members If Being Inherited From
private:
// Private Members Unique To This Derived Class
// ----- Member Function Section -----
public:
DerivedWithPossibleInheritance(); // Default Constructor
virtual ~DerivedWithPossibleInheritance(); // Virtual Destructor
void uniqueFunctionForThisClass() const;
void allDerivedMustImplement() const override;
private:
// Private Functions Unique To This Class
}; // DerivedWithPossibleInheritance
Derived Class That Can Not Be Inherited From
class DerivedClassCanNotBeInheritedFrom sealed : public BaseProtected {
// ----- Member Variable Section -----
public:
// Public Members Variables
protected:
// Should Not Have Member Variables Here For This Class Can Not Be Inherited from
private:
// Private Members Variables
// ----- Member Function Section ------
public:
DerivedClassCanNotBeInheritedFrom(); // Default Constructor
virtual ~DerivedClassCanNotBeInheritedFrom(); // Default Virtual Destructor
void anotherUniqueFunctionForThisClass() const;
void allDerivedMustImplement() const override;
protected:
// There Should Not Be Any Functions Here This Can Not Be Inherited From
private:
// Private Member Functions Here
}; // DerivedClassCanNotBeInheritedFrom
What I have demonstrated here is the key word sealed when working with inheritance and polymorphism. If you do not want your class to be derived from then use the sealed keyword.
As for declaring any base class, a stand alone class, or a singleton class that has a private Constructor the use of the friend keyword is needed. There are to many types of implementations to get involved with here to show them, but the concept of preventing a class from being inherited from is the same. Personally I have not used the keyword final, but I have used the keyword sealed and it works very good.
I have not used inheritance of classes other then public: So to answer your questions in terms of protected or private inheritance is not something I am real familiar with. But maybe the use of the keyword sealed might help you.