page591.html

来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 55 行

HTML
55
字号
<HTML><HEAD><TITLE>Classes</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html7940" HREF="page592.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7938" HREF="page585.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7932" HREF="page590.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html7942" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION0017400000000000000000">Classes</A></H1><A NAME="secpythonclasses">&#160;</A><P>A Python <em>class</em><A NAME=56921>&#160;</A>defines a data structure that containsinstance attributes, instance methods, and nested classes.In Python the class of an object and the type of an object are synonymous.Every Python object has is a class (type)that is directly or indirectly derived fromthe Python built-in <tt>object</tt> class.The class (type) of an object determines what it isand how it can be manipulated.A class encapsulates data, operations, and semantics.This encapsulation is like a <em>contract</em> betweenthe implementer of the class and the user of that class.<P>The <tt>class</tt> statement is what makesPython an <em>object-oriented</em> language.A Python class definition groups a set of values with a set of operations.Classes facilitate modularity and information hiding.The user of a class manipulates object instances of that class onlythrough the methods provided by that class.<P>It is often the case that different classes possess common features.Different classes may share common valuesand they may perform the same operations.In Python such relationships are expressed using<em>derivation</em> and <em>inheritance</em>.<P><BR> <HR><UL> <LI> <A NAME="tex2html7943" HREF="page592.html#SECTION0017410000000000000000">Instances, Instance Attributes and Methods</A><LI> <A NAME="tex2html7944" HREF="page593.html#SECTION0017420000000000000000">Example-Complex Numbers</A><LI> <A NAME="tex2html7945" HREF="page594.html#SECTION0017430000000000000000"><tt>__init__</tt> Method</A><LI> <A NAME="tex2html7946" HREF="page595.html#SECTION0017440000000000000000">Properties, Accessors and Mutators</A><LI> <A NAME="tex2html7947" HREF="page596.html#SECTION0017450000000000000000">Operator Overloading</A><LI> <A NAME="tex2html7948" HREF="page597.html#SECTION0017460000000000000000">Static Methods</A></UL><HR><A NAME="tex2html7940" HREF="page592.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7938" HREF="page585.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7932" HREF="page590.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html7942" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright &#169; 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a>  All rights reserved.</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?