Skip to content

cpp_inherit

ShenYj edited this page Aug 8, 2023 · 3 revisions

继承

C++ 继承语法

struct Person {};

struct Student: Person {};

struct Teacher: protected Person {};

C++中没有像Java、Objective-C的基类

成员继承,对象内存分布: 父类的成员会排在前面(低地址)

.

继承时设置访问权限:访问权限

并且 struct 和 class 相互继承

Getting Started

Social

Clone this wiki locally