我只是尝试从b2PolygonShape
创建b2Shape
,但我收到的错误是:Dynamic-cast from 'const b2Shape*' to 'b2PolygonShape*' casts away qualifiers
这是我的代码:
const b2Shape *s = fix2.shape;
b2PolygonShape *p = dynamic_cast<b2PolygonShape*>(s);
我做错了什么?
答案 0 :(得分:1)
编译器抱怨的是const
限定符。解决方案是
将p
声明为const b2PolygonShape
的指针:
const b2PolygonShape *p = dynamic_cast<const b2PolygonShape*>(s);