Why the below piece of code is not crashing , though i have deleted the object?

后端 未结 10 1218
北海茫月
北海茫月 2021-01-18 02:29
class object
{
  public:
    void check()
    {
      std::cout<<\"I am doing ok...\"<

        
10条回答
  •  不思量自难忘°
    2021-01-18 02:56

    Because the function is not doing anything with the object's member data or the this pointer.

    It's like calling a function

    void check(object *self)
    {
      std::cout<<"I am doing ok..."<

    with an invalid pointer as the self argument.

    There is a double delete though, which can crash in some environments.

提交回复
热议问题