Process-oriented: functional, C program and other object-oriented programming: C++,java,python Class and Object: Class: Is the abstraction of things, such as human, Ball object: Is an example of the class, such as football, basketball example shows: Ball can be the characteristics of the ball and behavior of the abstract, Then you can instantiate a real sphere. The main idea of object-oriented is: encapsulation, inheritance, polymorphic class definition (encapsulation): Classes combine the required variables and functions into a structure that encapsulates Class A (object) classes: Class Name: member Variable-property member Function-method Example:
# !/usr/bin/env python class People (object): Color = " yellow " def info (self): print " hello world! " print " i am a%s "% Self.color ren = people () Ren.info ()
The Info function (method) defined here Specifies the self parameter (the class itself), which means that the property of the class people is passed in, so that We can use the self. property directly inside the function to call here defines a class named people, which defines the member variable color, and defines the method info, the following ren = people () and so on people the instantiated object, We directly use this object to invoke the methods and properties of the class.
python-Object-oriented