에러?

class TestClass
{
public:
int TestFunc( int arg ) { return ( arg * 2 ); }
};
int main( int argc, char* argv[] )
{
TestClass* pt = NULL;
int ret = pt->TestFunc( 4 );
return ret;
}

인스턴스 없이 NULL 을 대입한 클래스 포인터로 멤버함수를 호출하였다.
이 프로그램을 실행하면 어떤 결과가 나올까?
단, 최적화 옵션이 낮게 설정되어 있어서 TestFunc 는 inline 처리가 되지 않았다.

by 이창연 | 2008/10/15 15:28 | 프로그래머 생각 | 트랙백(1) | 덧글(0)

트랙백 주소 : http://lisyoen.egloos.com/tb/2224255
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Tracked from Jong10++ at 2008/10/15 19:45

제목 : C++에서 null 포인터의 메소드 호출
이창연님의 블로그에 재밌는 글이 올라왔다. 아래 코드에 대한 것인데.. class TestClass { public: int TestFunc( int arg ) { return ( arg * 2 ); } }; int main( int argc, char* argv[] ) { TestClass* pt = NULL; int ret = pt->TestFunc( 4 ); return ret; } 인스턴.....more

:         :

:

비공개 덧글

◀ 이전 페이지다음 페이지 ▶