Private inheritance is a form of inheritance is which the public and protected portion of the base class becomes private in the derived class and the derived class has no access to the private members and methods of the base class.
Questions tagged [private-inheritance]
63 questions
-1
votes
3 answers
Private inheritance and returning references from functions
Now I have code below:
class Env
{
public:
int ra(){ return a;}
int rb(){ return b;}
private:
int a;
int b;
};
class CEnv: private Env
{
public:
static Env* Instance()
{
CEnv* pEnv = new CEnv;
return pEnv;
…

xingfu0539
- 62
- 6
-2
votes
3 answers
How do I access privately inherited class members in C++?
I'm trying to understand the private inheritance concept.
So far everywhere I see they write that private inheritance makes its members inaccessible from the derived class.
Doesn't this make it sort of useless? If I can't access the class inherited,…

Anonymous Guy
- 119
- 2
- 11
-3
votes
2 answers
Constructor is available outside of privately inheriting type?
The title is only one of a few things I am confused on about the following example:
struct A {
A() {
std::cout << "Default constructor of A" << std::endl;
}
A(const A &) {
std::cout << "Copy constructor of A" <<…

AlwaysLearning
- 7,257
- 4
- 33
- 68