【发布时间】:2014-12-17 22:02:25
【问题描述】:
void test()
{
Token test();
Actor* check;
check = dynamic_cast<Actor*>(test);
}
此方法给我以下错误,并用红色在大括号中的测试下划线。指针dynamic_cast的操作数必须是指向完整类类型的指针
我该如何解决这个问题?顺便说一下,Actor 继承自 Token。这是 Tokens 头文件中的代码。
#pragma once
#include <string>
class Token
{
public:
Token();
Token(int x, int y);
bool IsDead();
~Token();
char Symbol();
int X, Y;
bool clear;
bool indestructable;
int health;
int damage, rangeDamage;
//bool npc;
char character;
std::string ToString();
std::string name;
bool turnCompleted;
void SetProfile(char Name);
};
【问题讨论】:
-
在您的代码中,
test是一个函数。看起来您希望它是Token*。 -
为什么要尝试将令牌函数转换为actor指针?
标签: c++ dynamic-cast incomplete-type