저는 python에 대해 매우 익숙합니다. 일부 Python 코드로 작업하고 있습니다. Python 객체 지향 개념을 C++에 매핑하려고합니다. 배울 좋은 방법이라고 생각합니다. 건너 뛸 수 있습니다. 두 가지 유형의 클래스 정의.Python의 클래스 정의 구문
class SourcetoPort(Base):
""""""
__tablename__ = 'source_to_port'
id = Column(Integer, primary_key=True)
port_no = Column(Integer)
src_address = Column(String)
#----------------------------------------------------------------------
def __init__(self, src_address,port_no):
""""""
self.src_address = src_address
self.port_no = port_no
및 두 번째 것.
class Tutorial (object):
def __init__ (self, connection):
print "calling Tutorial __init__"
self.connection = connection
connection.addListeners(self)
self.mac_to_port = {}
self.matrix={}
SourcetoPort의베이스와 튜토리얼의 개체 사이의 차이점을 알고 싶습니다.
차이점은 무엇입니까? SourcePort는 Base에서 파생되었으며 Tutorial은 객체에서 상속됩니다. –
['object']에 대한 설명서는 다음과 같습니다 (http://docs.python.org/2/library/functions.html#object). [이 설명] (http://docs.python.org/2/glossary.html#term-new-style-class) (및 단락 하단에있는 링크)이 유용 할 수 있습니다. – Blender