U E D R , A S I H C RSS

Java Study2004/오버로딩과오버라이딩

2004 3번 문

, (Overriding) . 면, , .
를 들 People move(int aX, int aY){this.position.x += aX;this.position.y += aY;} . People Student . 데 '' . move . move(int aX, int aY){this.position.x -= aX;this.position.y -= aY;}
~cpp 
People people;// (100, 100)
people.move(10,10);// (110, 110)

Student student;// (100, 100)
student.move(10,10);// (90, 90)
만들 . 만, 를 만들는데 르면, .

받는 매 .
People move를 들. move 를 매. 만 people.move(1.1, 2.13)는 명면 매 . 더블 를 받 move를 Overloading. move(double aX, double aY){this.position.x += (int)aX;this.position.y += (int)aY;} . 는 매 . .
~cpp 
People people;// (100, 100)
people.move(10,10);// (110, 110)
people.move(5.1,11.8);//Overloading  ,  (115, 121)

Overriding Overloading . Overloading '무 많 ', '' , Overriding '무', '' . 미를 .

Thread

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:32
Processing time 0.0128 sec