essential c++ book note 4 chapter 5

本文探讨了面向对象编程的两大核心特性:继承与多态。继承允许我们创建类的家族,共享公共操作和数据,而多态则让我们能够将这些家族作为一个整体编程,而非单独的类。文中还解释了如何通过指针或引用间接操纵类对象,实现代码的灵活扩展。

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

chapter 5

object-oriented programming 

2 primary characteristics of object-oriented programming are Inheritance and Polymorphism

Inheritance: allows us to group classes into families of related types, allowing for the sharing of common operations and data.

Polymorphism: allows us to program these families as a unit rather than as individual classes.

the parent is called base class and child is called derived class 

 

1---in object-oriented programming, we indirectly manipulate the class objects through pointers or reference.(add or remove a derived class without the need for any modification to existing program)

void loan_check_in(LibMat &mat)   // no LibMat object in our application
{
   mat.check_in();   // mat refers to an actual object 
}

2 -- 

转载于:https://www.cnblogs.com/ggppwx/archive/2011/01/16/1936555.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值