小编Ing*_*ars的帖子

C++.在析构函数中调用虚拟成员函数

每个使用此调用进行扩展的类都会在析构函数中中止,并且调用堆栈告诉我调用abort的函数是从头文件中的不合理的位置调用的.其他函数被覆盖并且工作正常.

Renderable.h

#pragma once
class Renderable
{
public:
    virtual void update(long delta) = 0;
    virtual void destroy() = 0;
    virtual void render() = 0;
    virtual ~Renderable();
};
Run Code Online (Sandbox Code Playgroud)

Renderable.cpp

#include "Renderable.h"

Renderable::~Renderable()
{
    (this->*(&Renderable::destroy))(); // GLUtils::runOnUIThreadWithContext(this, &Renderable::destroy, true);
} // It says that it gets called from here.
Run Code Online (Sandbox Code Playgroud)

呼叫中止. 在此输入图像描述

c++ member-function-pointers

1
推荐指数
1
解决办法
102
查看次数

标签 统计

c++ ×1

member-function-pointers ×1