Why am I able to make a function call using an invalid class pointer

后端 未结 6 604
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 01:56

In below code snippet, although pointer is not initialized the call is still made successfully

temp *ptr;
ptr->func2();

Is it due to C++

6条回答
  •  温柔的废话
    2020-12-02 02:35

    You can call the methods using uninitialised pointers. It will work either ptr->func1(); or int crashere=ptr->func1();//

提交回复
热议问题