0

我正在尝试执行以下演员,但我无法在 QT 文档或在线找到一种方法来使这种令人困惑的动态演员工作:

class Entity : public QSharedData
{
  public:
    typedef QExplicitlySharedDataPointer<Entity> Pointer;
    typedef QExplicitlySharedDataPointer<const Entity> ConstPointer;
...
}

class EntityExtended : public Entity
{
public:
    typedef QExplicitlySharedDataPointer<EntityExtended> Pointer;
    typedef QExplicitlySharedDataPointer<const EntityExtended> ConstPointer;
...
}



bool SomeClass::createEntity(const Entity::ConstPointer entity)
{
  auto extendedEntity = dynamic_cast<const EntityExtended::ConstPointer>(entity);
}

以上产生错误:

error C2680: 'const EntityExtended::ConstPointer': invalid target type for dynamic_cast
note: target type must be a pointer or reference to a defined class

我错过了什么?

4

0 回答 0