A destructor method in a class Within a class, a destructor method lets the class perform “cleanup” processing before the garbage collector(GC) releases the memory that holds an object.I explained GC through last lecture. Let’.....
A destructor method in a class Within a class, a destructor method lets the class perform “cleanup” processing before the garbage collector(GC) releases the memory that holds an object.I explained GC through last lecture. Let’.....
학생 클래스를 구현해보자. ① 학생 한명의 정보를 입력받아 출력하는 간단한 프로그램이다. ② 학생정보는 이름, 나이, 전화번호, 주소로 구현된다. 멤버변수는 private으로 선언하며, 주소는 char포인터(char*)형으로 선언한다. 즉, 주소는 넘겨받은 길이만큼 .....
오늘 같이 일하는 분들 중 가운데 한분으로부터 왜 제 프로그램을 실행시키면 destructor가 2번 불리는 거죠?라는 질문을 들었습니다.소멸자는 명시적으로 불러주지 않는 한 (뭐 가령 obj.TheClass::~TheClass()와 같이 해 주지 않는 한) 절대로 두 번 불리지 않습니다......
C++ 생성자의 virtual 함수 C++에서 생성자에서는 virtual 함수를 불러도 제대로 동작하지 않는다. 다음과 같은 샘플의 예에서 derived 클래스에서 소멸자 ~derived는 ~base대신에 출력되지만 생성자의 경우는 생성자의 virtual 자체가 없기 때문에, derived(.....