什么是类
类:是一组相关属性和行为的集合。可以看成是一类事物的模板,使用事物的属性特征和行为特征来描述该 类事物。
举例:小猫。
属性:名字、体重、年龄、颜色。 行为:走、跑、叫。
什么是对象
类的具体体现,实现。
举例:一只小猫。
属性:tom、5kg、2 years、yellow。 行为:溜墙根走、蹦跶的跑、喵喵叫。
类与对象的关系
类是对一类事物的描述,是抽象的。
对象是一类事物的实例,是具体的。
类是对象的模板,对象是类的实体。
对象是根据类来创建的,类中有什么对象就有什么