赞
踩
在 C 语言面向对象编程(一)里说到继承,这里再详细说一下。
C++ 中的继承,从派生类与基类的关系来看(出于对比 C 与 C++,只说公有继承):
先看 C 语言中通过“包含”模拟实现继承的简单代码框架:
- struct base{
- int a;
- };
-
- struct derived{
- struct base parent;
- int b;
- };
-
- struct derived_2{
- struct derived parent;
- int b;
- };
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。