#include <iostream>
#include<iomanip>
using namespace std;
class Player {
public:
Player() {
cout << "Player 생성자 호출" << endl;
_hp=0;
_attack=0;
_defence=0;
}
Player(int hp) {
cout << "Player(int hp) 생성자 호출" << endl;
_hp = hp;
_attack = 0;
_defence = 0;
}
~Player() {
cout << "Player 소멸자 호출" << endl;
}
void Move() { cout << "Player Move" << endl; };
void Attack() { cout << "Player Attak" << endl; };
void Die() { cout << "Player Die" << endl; };
public:
int _hp;
int _attack;
int _defence;
};
class Knight :public Player{
public:
Knight() {
cout << "Knight 생성자 호출" << endl;
}
Knight(int stamina):Player(100)
{
_stamina = stamina;
cout << "Knight(int stamina) 생성자 호출" << endl;
}
~Knight() {
cout << "Knight 소멸자 호출" << endl;
}
void Move() { cout << "Knight Move" << endl; };
void Attack() { cout << "Knight Attak" << endl; };
void Die() { cout << "Knight Die" << endl; };
public:
int _stamina;
};
class Archer :public Player {
public:
Archer() {
cout << "Archer 생성자 호출" << endl;
}
~Archer() {
cout << "Archer 소멸자 호출" << endl;
}
void Move() { cout << "Archer Move" << endl; };
void Attack() { cout << "Archer Attak" << endl; };
void Die() { cout << "Archer Die" << endl; };
public:
int _arrow;
};
class Mage :public Player {
public:
Mage() {
cout << "Mage 생성자 호출" << endl;
}
~Mage() {
cout << "Mage 소멸자 호출" << endl;
}
void Move() { cout << "Mage Move" << endl; };
void Attack() { cout << "Mage Attak" << endl; };
void Die() { cout << "Mage Die" << endl; };
public:
int _mp;
};
int main()
{
Knight k1(50);
Archer a1;
Mage m1;
k1.Move();
m1.Attack();
a1.Die();
k1.Player::Move();
return 0;
}