类的继承_子类继承父类

[root@blackfox zhouyuyao]# cat c5.py 

#!/usr/bin/python

#coding:utf-8


class People(object):

    color = 'yellow'


    def __init__(self,c):

        print "Init..."

        self.dwell='Earth'


    def think(self):

        print "I am a %s" % self.color

        print "I am a thinker."


class Chinese(People):

    def __init__(self):

#        People.__init__(self,'red')

        super(Chinese,self).__init__('red')         //super函数

    pass


cn=Chinese()

[root@blackfox zhouyuyao]# python c5.py 

Init...


上一篇:COM/DCOM开发练习之进程内组件实例


下一篇:cmake指定输出安装目录