1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/usr/bin/python
class QBaseObject(object): #define base class
"base class"
value = 0
def __init__(self):
print "QBaseObject no param"
def __init__(self,name):
self.name = name
print "QBaseObject param name:",self.name
def setName(self,name):
self.name = name
def getName(self):
return self.name;
class QPerson(QBaseObject):
"""QPerson class"""
def __init__(self, address):
super(QPerson, self).__init__()
self.address = address
print "QPerson address"
def __init__(self, name,address):
super(QPerson, self).__init__(name)
self.address = address
print "QPerson name &address"
#p1 = QPerson("北京市朝阳区")
#print "p1 name = %s, address = %s value = %d" % (p1.name,p1.address,QPerson.value)
p2 = QPerson("ksnowlv","北京市朝阳区")
QPerson.value = 1
print "p2 name = %s, address = %s value = %d" % (p2.name,p2.address,QPerson.value)
p2.setName("kAir")
QPerson.value = 2
print "p1 name = %s, address = %s value = %d" % (p2.name,p2.address,QPerson.value)
p2.setName("ksnowlv")
print "p2 名字还原为",p2.getName()
|