[問題] 透過 null pointer 呼叫 member function
不好意思,謝謝。
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
只是一個Pointer卻可以執行Funtion,debug過程也確定其值為null。不太了解
餵入的資料(Input):
無
預期的正確結果(Expected Output):
error
錯誤結果(Wrong Output):
螢幕印出 : I AM HERE
程式碼(Code):(請善用置底文網頁, 記得排版)
class test
{
public:
void print()
{
cout << "I AM HERE" << endl;
}
};
int main()
{
test* p1 = NULL;
p1->print();
}
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.170.17
※ 編輯: crazycat2 來自: 118.160.170.17 (02/25 17:51)
推
02/25 17:58, , 1F
02/25 17:58, 1F
→
02/25 17:59, , 2F
02/25 17:59, 2F
→
02/25 18:00, , 3F
02/25 18:00, 3F
推
02/26 17:10, , 4F
02/26 17:10, 4F