2011년 4월 13일 수요일

cpp] 예제로 바로 알아보는 c와 c++ - 38

#include <iostream.h>
class A {
 int * p;
public:
 A();
 ~A();
};
A::A()
{
 cout << "Constructor\n";
// p = new int;
}
A::~A()
{
 cout << "Destructor\n";
// delete [] p;
}
void main(void)
{
 A *p;

 p = new A[3];

 cout << *(int*)((char*)p-16) <<endl;

// delete p; //주석제거하면 에러남. 소멸자가 들어가면
}

왜일까? 소멸자 들어가는데 에러가 날까?

댓글 없음:

댓글 쓰기

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...