Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the inheritance and derivation of C++

Shulou Source: shulou.com Published: 2022-06-01 06:16:37 10月05日 Update

This article mainly introduces "what is the inheritance and derivation of C++". In daily operation, I believe many people have doubts about the inheritance and derivation of C++. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what is the inheritance and derivation of C++"! Next, please follow the editor to study!

/ / parent base class class parent {}; / subclass derived class / / public inheritance class soon1:public parent {public: protected:}; / / protect inheritance class son2:protected parent {public: protected:}; / / private inheritance class son3:private parent {public: protected:} / / inheritance and derivation / / inheritance: no new attributes and behaviors are generated in subclasses / / derivation: new attributes and behaviors in derived classes generate class subclass names: inheritance mode parent class name {}; / / inheritance mode is the essence of permission qualifier inheritance and permission problems

The essence of inheritance: there is one of the data and member subclasses of the parent class

Permission problem: inheritance will only enhance the display of permissions for parent class properties in subclasses

Publicprotectedprivatepublic inheritance publicprotected cannot be directly accessed protected inheritance protectedprotected cannot be directly accessed private inheritance privateprotected cannot be directly accessed # include#includeusing namespace std;class parent {public: void print () {cout

Tags: Subclasses attributes caching permissions learning private way problem substance more behavior help utility next function writing function that is member data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft MariaDB OPPO Reno Shulou Technology