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..
class TempComponent extends Component{ constructor(props){ super(props); } render(){ return(); } } React에서 Component를 생성할 때 state 값을 초기화하거나 메서드를 바인딩할 때 construcotr()를 사용합니다. React의 Component의 생성자는 해당 Component가 마운트 되기 전 호출됩니다. React.Component를 상속한 컴포넌트의 생성자를 구현할 때는 super(props)를 선언을 권고하고 있습니다. 이유는 this.props 사용 시 생성자 내에서 정의되지 않아 버그 발생 가능성이 생기기 때문입니다. class TempComponent extends Component{ constr..