【发布时间】:2015-12-30 21:11:46
【问题描述】:
使用 this 扩展的每个类都在析构函数中调用 abort,调用堆栈告诉我调用 abort 的函数是从头文件中不合理的位置调用的。其他函数被覆盖并且工作正常。
可渲染.h
#pragma once
class Renderable
{
public:
virtual void update(long delta) = 0;
virtual void destroy() = 0;
virtual void render() = 0;
virtual ~Renderable();
};
可渲染.cpp
#include "Renderable.h"
Renderable::~Renderable()
{
(this->*(&Renderable::destroy))(); // GLUtils::runOnUIThreadWithContext(this, &Renderable::destroy, true);
} // It says that it gets called from here.
【问题讨论】:
-
你为什么不
press retry to debug the application?你为什么不直接打电话给destroy()? -
whattttt arrreee youuuu doinnnggggggg
-
你知道
(this->*(&Renderable::destroy))();只是写destroy();的荒谬复杂的方式吧?
标签: c++ member-function-pointers