Visibility modes in Classes - c++

We know that private members are not inherited whenever we inherit a base class to get a derived class, but is it possible for derived class member functions to access
the private members of the base class?

Private members are inherited, but they are not accessible. They are "private" for a reason. However, if your derived class needs to access them, it should be declared a friend to the base class.

Private members of the base class are inherited by the derived class, but are not (directly) accessible to it. They may still be accessed by protected and public members of the base class. As Hosam Aly says above one could access base class members by making derived class functions friends of the base class, or by turning the private members of the base class into protected members of the base class, whichever is preferable.

Related

Hiding the base class but not its members in Doxygen

I am documenting a few classes with Doxygen.
My class graph features a generic base class which is inherited by others. I do want the members of the base class to be listed in the derived classes (in a "Public members inherited from…" section). But I don't want the base class to appear stand-alone.
If I uncomment the base class and activate the HIDE_UNDOC_CLASSES flag, the base class completely disappears, even in the inherited sections of the derived classes, even though I left comments on the base members. This is not what I want.
Do you know a way to achieve this effect ?

About Inheritance in c++

If a class is inherited in public mode so public members and protected members of base class will go in public and protected section of derivied class.
My question is: if there is no protected section in derived class then what will happen?
Nothing will "happen". The class simply will not have protected members other than those of its base(s).
If you don't write protected:, that doesn't mean the class is incapable of having [inherited] protected members, or that it has no "protected section". Syntax and semantics are not that tightly coupled.
With public inheritance, it does not matter if derived class has no protected section at all in its definition, or if it is empty. The protected members of base class are inherited anyway and remain protected. Same for public, even if derived class has no public section in its definition.
The public:/protected:/private: in calss definitions are not really "sections", they are just syntax to mark member access for the members following them until the next public:/protected:/private:, and you can have any number of such "sections" in any order.

Does the base have any information about the classes derived from them?

this question was asked on a site I thought it must be having an information about it as when we create an abstract class it is the condition that pure virtual function must be implemented in the derived class.
The base class doesn't have any info about their subclasses.
Its subclasses have info about base class.
Generally it depends what you name "Information"
If you have declared virtual functions inside a base class
You can say the compile generates a Jump list inside the base class and when you derive from that base class and declare a function that has the same declaration as the virtual base class function the compiler just place the address of the function from the derived class to that jumplist in base class.
And this of course is done by the derived class.
if you have an inheritance chain the last instantiated class will place the address of its function. And when the base class tries to call the function it just uses the jump list to jump to right function.

what is the difference between public members and publicly inherited protected members? [duplicate]

This question already has answers here:
What is the difference between public, private, and protected inheritance in C++?
(16 answers)
Closed 9 years ago.
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. but if we inherit protected members publicly , we can inherited it further.)
A public method is visible to everyone.
A publicly inherited protected method is still protected, i.e. visible to the class itself and any derived classes.
Public member can be accessed from any class using object of that class and for accessing public members you do not have to inherit that class but to access protected members you have to inherit it. Mind it if a member is declared protected in the base class and you inherited publicly then also this member will be considered as protected member of derived class.
Public members can also be accessed by other classes (not just derived) and everywhere in general.
Well, public inheritance is your "normal" inheritance, so the semantics of public and protected members in this case are exactly what you'd think they are.
That is, your public members are public, and your protected members are visible only to the current and more-derived classes.
It's basically only when you start using private/protected inheritance that things get dicey and confusing and strange.
1:If protected members inherited by public then child class can
access it as well as it will remains protected in child class so that
we can access this member in next child class.
2: If protected members inherited by private then child class can
access it and it will make private in child class so that we can'not
access this member in next child class.
A public member is public. A protected member is protected. It doesn't matter whether they got there by being defined directly or being inherited from a public base.

difference between interface inheritance and implementation inheritance

I found those two terms in the book of Meyers, but what is the difference?
Interface inheritance is public inheritance, while implementation inheritance is private inheritance.
If class B publicly inherits from A, B is an A: it inherits the whole interface of A, and a (reference/pointer to) a B object can be automatically be upcasted to A, and used wherever an object of A is expected. However, if B privately inherits from A, B is-implemented-in-terms-of A: only the implementation of A is inherited, not its interface. Thus (references/pointers to) B objects can not be used in places where A objects are expected.
Update
To reflect on #Michal's comment, here are some links (based largely on googling "c++ implementation inheritance") to demonstrate the common usage of these terms in the context of C++:
C++ Design/Coding tips - Part 7
Interfaces
Uses and Abuses of Inheritance, Part 1
Implementation (or class) inheritance is when you separate a common part of implementation in the base class.
Interface inheritance is when you use virtual methods. It is intended to separate interface from implementation and minimize dependencies between program elements.
The major difference is interface is public inheritance and implementation is private inheritance.
The data members and method of the public and protected section will be inherited from base class to derived class in their respective access specifier in public inheritance.At the same time the object of derived class can access the data members of base class as the normal method.
The data members and methods of public and protected section will be inherited from base class to derived class in private access specifier
Here's the difference between the two types of inheritance according to "Taligent's Guide to Designing Programs".
Inheritance
There are two forms of inheritance in C++: type inheritance and implementation inheritance. In both forms of inheritance, a derived class can share or override behavior inherited from a base class. However, use type inheritance only when it is necessary for a derived class to inherit type information as well. The primary reason to inherit type information is to allow for polymorphism.
Express type inheritance by deriving a class from a public base class; express implementation inheritance by deriving a class from a private or protected base class.
More at:
https://root.cern/TaligentDocs/TaligentOnline/DocumentRoot/1.0/Docs/books/WM/WM_23.html