Python 面向对象 3 继承 has/a 是/a 多继承
发布时间
阅读量:
阅读量
目录
1.具有
2.属于
3.多重继承
4.多态性
1.has a
> 1. # has a:一个类中使用了另外一种自定义的类型(如Car中使用Road类)
>
> 2. # 自定义类型:自定义的类
>
> 3. # 系统类型:str,int,float.tuple,set,dict,list.......
>
>
>
>
> ```
>
>
import random
class Road:
def __init__(self,name,len):
self.name = name
self.len = len
class Car:
def __init__(self,brand,speed):
self.brand = brand
self.speed = speed
def get_time(self,road): # road是一个类对象
ran_time = ra
全部评论 (0)
还没有任何评论哟~
