The Basic Principle of OOP OF C++
1.Object send and receive messages(objects do things)the messages are :
- composed by the sender
- interpreted by the receiver
- implemented by methods
the messages
- may cause receiver to change state
- may return results
2.Object vs Class
object (cat)
- represent things , event , or concept
- respond to message at run-time
classes (cat class)
- define properties of instances
- act like types in c++
3.OOP CHARACTERISTICS
- Everything is an object
- A program is a bunch of object telling each other what to do by sending messages.
- Each object has its own memory made up of other objects.
- Every object has a type.
- All objects of a particular type can receive the same messages.
4.An object has an interface
- The interface is the way it receives messages.
- It is defined in the class the object belong to.
5.Functions of the interface ( coupling )
- Communication
- Protection
6.The Hidden Implementation
- Inner part of an object , data members to present its state , and the actions it takes when messages is received is hidden.
- Class creators vs Client programmers
- Keep client progrmmers' hands off portions they should not touch.
- Allow the class creators to change the internal working of the class without worrying about how it will affect the client programmers.
7.Encapsulation
- bundle data and methods dealing with these data together in an object .
- hide the details of the data and the action .
- restrict only access to the publicized methods.
评论