c++ 中的多重继承和其权限问题

本文探讨了C++中类的三种继承方式:私有(private)、公有(public)和受保护(protected)。解释了这些不同权限如何影响成员变量和方法的可访问性,包括构造函数和虚方法的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   There are three way to extend in c++,private,public and protected,If the method's permission is private,whatever the method of extend,the member is we can't use.protected like private in some aspects.The member in the class is not  available.But the class extends it the method in later class can use the member.This is the difference between private and protected.The constructor in the father class can't be extends .So we should write the constructor to construct the class .we can write the constructor by the constructor in the father class.Virtual method in the class can help us avoid the some extends from the father class .Object in the class usually be named as son object . The assignment we only can't make the son class equal father class . But we can make the father class equal son class.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值