示例#1
0
 static void attackCount(StarUnit starUnit, int cnt)
 {
     for (int i = 0; i < cnt; i++)
     {
         starUnit.attack();
     }
 }
示例#2
0
        static void attackCount(StarUnit starUnit, int cnt)
        {
            // attack() 메서드를 호출할 때
            // virtual이 있으면
            // 컴파일 시 메서드를 결정하지 않는다
            //
            // 실행 시 객체내에 있는
            // virtual table을 참조해서
            // 해당 객체의 attack()메서드를
            // 호출한다.
            // 이것을 '동적 바인딩' 이라 부른다

            for (int i = 0; i < cnt; i++)
            {
                starUnit.attack();
            }
        }