Home > database >  The third chapter object-oriented
The third chapter object-oriented

Time:09-30


3. 1 oo
Object: class=& gt; Things
1
3. 1.1) object oriented analysis: 00 (a) determine requirements or business point of view, to analyze the business according to the object-oriented thought,
00 2) object-oriented design (d) : the middle transition link, function based on 00 a further standardization,
3) object oriented programming (00 p) : on the basis of the former two, further refine the data model, the oop is based on a true object to build the application model of opp is the current mainstream software model of software development, master of opp is the key to write high quality program,
1. Object:
All things are objects; Using data values to describe themselves with the state; Also has the behavior, behavior can change the state of an object, the object will encapsulate data and behavior at an organic whole,
2. Categories:
The same or similar object abstraction, the object is abstract class; Class is composed of characteristics and behavior,
Is characterized by the state of the object abstraction, use variables to describe the characteristics of the class, also known as attributes,
Operation of abstraction, usage behavior is object to describe the behavior of the class,
A class can have multiple instantiation object, the object is a specific thing,
Relationship: class or relationship;
And relationship;
The object-oriented features:
1. 2. The uniqueness sorted 3. Encapsulation 4. 5. Inheritance polymorphism
The main three kinds:
Encapsulation: the object's state members (properties) and behavior (members) together, formed an integral and independent unit (objects), as far as possible the internal details of foreign hidden objects, retain only limited contact external interface with external,
Inheritance: a subclass automatically inherit properties and methods of the parent,
Polymorphism: will the same operation process can be applied to many types of objects and get different results on different objects receive the same message can produce different results, which have different performance, this phenomenon is called polymorphism,
3.2.1 class statement
Class defines a new data type, with the same attributes and common behavior (method) of the set of a set of objects,
Create objects need to use the new keyword
Syntax format: name of the class object name=new class name ();
Methods:
Syntax format: public void method name ([parameter list])
Access attributes of the object: the object name. The property name
Calls the method: the object name. The method name ()
Method is the behavior of the class:
Syntax format: [accesses] [modifier] Method body
}
Methods can take parameters, through arguments can be passed to a method data,
Parameter and argument passing way:
Reference data type - address: participation between arguments, arguments to address to the parameter, the called method by passing the address of its point to memory space, and in the original memory,
Basic data types -- the value transfer: form to participate in the argument between
Parameters: the method name (data type parameter)
Argument: the object name. The method name (arguments)
Method:
Is a special class of methods, for creating object initialization object attribute values,
Note: the method name is the same as the name of the class
Methods former has no return value type declaration, no void
Can't use the return statement to return values
The default constructor:
The person () method to construct
Once created its own constructor, the default constructor will cease to exist, a constructor cannot be used in static variables,
Method overloading:
Do two or more methods in the same class name is the same but different column is called method overloading,
Three principles:

1. In the same class2. The same method name
3. Different parameter list
This key word:
Represent the current class of object in the future, where the object is used to obtain the new came out when included in the object's reference,
This {represents the current object of a class; On behalf of the class constructor}
A
1. The member variables initialization:
2. Plants: object=& gt; Create initialization
3. Create an object called when constructing new
4. The program automatically creates a default constructor

  • Related