Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

HardcoreCppStudy/두번째숙제/ConstructorAndDestructor/김아영

From ZeroWiki
Revision as of 05:23, 7 February 2021 by imported>Unknown
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

* 생성자란?

  • 생성자(Constructor) 클래스 이름과 같은 이름을 지닌 함수
  • 클래스의 객체가 생성될 때, 자동으로 호출
  • 주로 변수에 대한 초기화 작업을 수행
  • 형식
       //private 자료 정의 
public : 
       클래스이름(  ){           } //생성자 함수정의  
       //클래스 멤버 정의 
}; 

* 소멸자란?

  • 객체가 소멸될 때 수행해야 할 작업들을 위한 함수
  • 기억장소를 반납하는 목적
  • 형식
       //private 자료 정의 
public : 
       ~클래스이름(  ){           } //소멸자 함수정의  
       //클래스 멤버 정의 
};