Reusing Code in C++: inheriting and template

本文探讨了C++中代码复用的主要方式——继承和模板。通过对象和类创建程序是面向对象编程的核心,而继承是创建不同对象的一个子问题。公共、保护和私有继承提供了对基类成员的不同访问级别,模板则为泛型编程提供了手段,允许根据不同的类型生成代码。理解继承的本质和正确使用继承与模板,可以实现更高效且灵活的代码设计。
摘要由CSDN通过智能技术生成
Reusing Code in C++: inheriting and template
The worldview of Object-oriented means a lot, including taking an object-oriented perspective to observe things and solve problems. OOP means that creating programs by using objects and creating objects. For an OOP program, the first thing a programmer thinks is what the objects the program would use to solve the problem and build the system, but not solving problem itself. Using and creating different objects are daily common through reusing provided code. Objects are the elements of the program.

Creating new objects by instancing new classes which are the inheritances of old classes is a sub-problem of creating different objects.

All efforts of reusing code in C++ serves classes-creating or type-creating which serves objects-creating. The program uses objects to build systems and solve the problem.




What is inheritance? Why is this facility designed like this? How to understand the Is-a relationship and has-a relationship?

In real and artificial world, the features of more complicated and concrete things or objects are sets of simple and abstract features! So, using integrated sets of abstract concepts and features to describe a special object is a natural developed thought. This thought or process of thinking can be utilized to model concepts from more general to more special!

Formal language with its self-contained is symbolized and information-condensed, formally, also describes the abstract concepts and relationship among them, for example, as mathematics does. Using formal language to model system and represent problem is amazing and powerful. Computer language is one of formal language. Using the thought(the process of t
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值