객체지향 (OOP Object Oriented Programming)
class Player
{
public:
Player()
push ebp
mov ebp,esp
sub esp,0CCh
...
pop ecx
mov dword ptr [this],ecx
...
{
_hp = 0;
mov eax,dword ptr [this]
mov dword ptr [eax],0
_attack = 0;
mov eax,dword ptr [this]
mov dword ptr [eax+4],0
_defence = 0;
mov eax,dword ptr [this]
mov dword tpr [eax+8],0
cout << "Player 생성자 호출" << endl;
}
~Player()
{
cout << "Player 소멸자 호출" << endl;
}
void Move() { cout << "Player Move 호출" << endl; }
void Attack() { cout << "Player Attack 호출" << endl; }
void Die() { cout << "Player Die 호출" << endl; }
public:
int _hp;
int _attack;
int _defence;
};
class Knight : public Player
{
public:
Knight()
call Player::Player (...)
mov dword ptr [ebp-4],0
{
cout << "Knight 생성자 호출" << endl;
}
~Knight()
{
cout << "Knight 소멸자 호출" << endl;
}
mov ecx,dword ptr [this]
call Player::~Player (...)
mov ecx,dword ptr [ebp-0Ch]
int _stamina;
};
class Mage : public Player
{
public:
int _mp;
};
int main()
{
Knight k;
lea ecx,[k]
call Knight::Knight (0DA1442h)
mov dword ptr [ebp-4],0
k._hp = 100;
mov dword ptr [k],64h
k._attack = 5;
mov dword ptr [ebp-20h],5
k._defence = 8;
mov dword ptr [ebp-1Ch],8
k._stamina = 10;
mov dword ptr [ebp-18h],0Ah
k.Move();
lea ecx,[k]
call Player::Move (...)
}
mov dword ptr [ebp-4],0FFFFFFFFh
lea ecx,[k]
call Knight::~Knight (...)