| boqian2000 (16) | |
|
Every C++ programmer must have used public inheritance already, but not everyone has used protected or private inheritance. What are they? What's the usage of them, if any? class yellowdog : private dog { }; http://www.youtube.com/watch?v=EYuPBkgJtCQ | |
|
|
|
| Stewbond (1673) | ||
From: http://cplusplus.com/doc/tutorial/inheritance/
It means that public and protected members of dog are now private members of yellowdog. Where is it useful? Let's say that you want to create a wrapper for the std::fstream class. You could choose to inherit from std::fstream. If you don't want the member functions to be available to the outside world, you could inherit it privately. | ||
|
Last edited on
|
||