Linked Questions
118 questions linked to/from What is the difference between public, private, and protected inheritance?
50 votes
2 answers
183k views
What are access specifiers? Should I inherit with private, protected or public? [duplicate]
I am confused about the meaning of access modifiers with respect to inheritance. What is the difference between inheritance involving the private, protected and public keywords?
16 votes
1 answer
9k views
c++ inheritance syntax [duplicate]
Possible Duplicate: What are access specifiers? Should I inherit with private, protected or public? Difference between private, public and protected inheritance in C++ To all you cpp experts, In ...
9 votes
5 answers
4k views
What is difference between protected and private derivation in c++ [duplicate]
Possible Duplicate: Difference between private, public and protected inheritance in C++ What is difference between deriving as protected or private in c++? i am not able to figure out, since both ...
0 votes
1 answer
4k views
Variable inaccessible despite class inheritance? [duplicate]
I am having a hard time trying to understand why the variable engineNum is inaccessible from within the function in the class Pickup. My basic understanding is, if the class is inherited the private ...
8 votes
2 answers
184 views
Private inheritance causing problem in c++ [duplicate]
Why would the following code run into error of ‘A’ is an inaccessible base of ‘B’? Here's my thoughts: whenever we call function foo(), it will execute new B(5), which will first call the constructor ...
0 votes
3 answers
2k views
Class member visibility within inheritance c++ [duplicate]
I was looking up some unknown book about C++. and faced with this table which title reads. " ― As the result of inheritance all fields of base class are being inherited by derived class." ...
2 votes
1 answer
742 views
Protected Inheritance in C++ [duplicate]
Simple code: class A { private: int a; protected: int b; public: int c; }; class B : protected A { }; class C : protected B { }; I know in Class B, a will remain private & b and c are ...
-1 votes
1 answer
605 views
When defining a derived class, why is the base class marked "public?" [duplicate]
Possible Duplicate: Difference between private, public and protected inheritance in C++ One of the examples in my lecture notes is class TransportShip : public GameUnit { int capacity; ...
0 votes
2 answers
218 views
Why can't I access the private variables using an inheriting class? [duplicate]
I'm trying to inherit some private members of a class. I'm not going to put any of the other cpp files or .h files because this should only concern BoxClass.h, Bullet.h, and Bullet.cpp. In bullet.cpp ...
-3 votes
1 answer
402 views
Why can't we change the access level of functions in base class in inheritance? [duplicate]
In the following code, if the base class is derived as protected then the code doesn't work. Why? When exactly are protected and private access specifiers used when inheriting base class having ...
-1 votes
1 answer
243 views
conditions for type casting in C++ [duplicate]
I was reviewing inheritance and I saw the three rules of casting based on the following code. (from https://www.youtube.com/watch?v=EYuPBkgJtCQ) class B{}; class D_priv: private B{}; class D_prot: ...
-3 votes
1 answer
183 views
linked list without inheritance [duplicate]
I created a linked list in c++. First I created a class Node then another class called List. My program runs perfectly. The thing is, I don't understand why there is no inheritance between Node and ...
0 votes
2 answers
108 views
Why sub class manage to access c++ private inheritance member? [duplicate]
My questions is why b.getmultiply(); will not cause compilation error? Class B is private inherit from class A, and x and y are members of class A. class A { public: int x; int y; ...
1 vote
1 answer
159 views
What happens under the hood when assigning derived class pointer to base class pointer in C++ [duplicate]
I came across this question while experimenting with following simple code. #include <iostream> using namespace std; class A{ public: A(){ cout << "Def contr A" << ...
-5 votes
6 answers
252 views
what is the difference between public members and publicly inherited protected members? [duplicate]
what is the difference between public members and publicly inherited protected members? (as it is said that protected members can only be accessed by the base class and immediate next derived class. ...