面向对象的意义在于:c++
类和对象是面向对象中的两个基本概念设计
一个类能够有不少对象,而一个对象必然属于某个类code
类之间的基本关系对象
继承:继承
组合编译器
继承是单向的,子类继承父类全部的属性和行为产品
#include <stdio.h> struct Biology { bool living; }; struct Animal : Biology { bool movable; void findFood() { } }; struct Plant : Biology { bool growable; }; struct Beast : Animal { void sleep() { } }; struct Human : Animal { void sleep() { } void work() { } }; int main() { return 0; }
类之间能够存在继承关系或组合关系继承关系中子类拥有父类的一切属性和行为io
组合关系是类之间总体和部分的关系编译
类及类之间的关系能够有不一样的表示法ast
编译器对类的表示法有具体的要求