#include <iostream>
#include<iomanip>
using namespace std;
class Knight {
public:
Knight(){
cout << "Knight() 기본 생성자 호출" << endl;
_hp = 100;
_attack = 10;
_posY = 0;
_posX = 0;
}
Knight(const Knight& knight) {
cout << "Knight() 복사 생성자 호출" << endl;
_hp = knight._hp;
_attack = knight._attack;
_posY = knight._posY;
_posX = knight._posX;
}
explicit Knight(int hp) {
cout << "Knight() 타입 변환 생성자 호출" << endl;
_hp = hp;
_attack = 10;
_posY = 0;
_posX = 0;
}
~Knight() {
cout << "Knight() 소멸자 호출" << endl;
}
void Move(int y, int x);
void Attack();
void Die() {
this->_hp = 0;
cout << "Die" << endl;
}
public:
int _hp;
int _attack;
int _posY;
int _posX;
};
void Knight::Move(int y, int x){
cout << "Move " <<"x: "<<x<<" y: "<<y<< endl;
}
void Knight::Attack(){
cout << "Attack " << _attack << endl;
}
void HellowKnight(Knight k) {
cout << "Hello" << endl;
}
int main()
{
Knight k1;
Knight k2(80);
Knight k3 = k1;
Knight k5;
k5 = (Knight)1;
k3.Move(2, 2);
k3.Attack();
k3.Die();
int num = 1;
float f = num;
f = (float)num;
HellowKnight((Knight)5);
return 0;
}