메세지 (Message)
메세지 (Message)
- 객체 접근 방법
- One object accesses another object by sending it a message.
- The only way one object should access another.
- An object-oriented program is a system of communicating objects.
- 메세지
- A message consists of the name of operation and any required arguments:
. - myPoint . move (10, 2);
myPoint . setcolor (blue);
- The set of messages to which an object can respond is known as the behavior or protocol of the object.
송신 객체
Operation Name
& Arguments
수신 객체
Notes:
- example
- class point {
int xPosition;
int yPosition;
colorType color;
public:
...
void move (int x, int y) {...
void setColor (colorType c) {...
}
- Point myPoint;
myPoint.move (10, 15);
myPoint.setColor (blue);