C++ #03 생성자와 소멸자
C++
2021. 11. 29. 14:31
03. 생성자와 소멸자 생성자 C++에서 생성자(Constructor)를 이용해 객체를 생성함과 동시에 멤버 변수를 초기화 할 수 있다. 생성자는 특별한 메소드로 클래스 이름과 동일한 이름으로 구현된다. 생성자의 특징 생성자는 반환값이 없음 생성자는 여러번 정의 될 수 있음(매개변수 다양화) #include #include using namespace std; class Character { private: string name; int ragePoint; int hp; int damage; public: Character(string name, int hp, int damage) { this->name = name; this->ragePoint = 0; this->hp = hp; this->damage..