Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是想b2PolygonShape从 a创建一个,b2Shape但我遇到一个错误,上面写着:Dynamic-cast from 'const b2Shape*' to 'b2PolygonShape*' casts away qualifiers
b2PolygonShape
b2Shape
Dynamic-cast from 'const b2Shape*' to 'b2PolygonShape*' casts away qualifiers
这是我的代码:
const b2Shape *s = fix2.shape; b2PolygonShape *p = dynamic_cast<b2PolygonShape*>(s);
我究竟做错了什么?
这是const编译器抱怨的限定符。解决方案是声明p为指向的指针const b2PolygonShape:
const
p
const b2PolygonShape
const b2PolygonShape *p = dynamic_cast<const b2PolygonShape*>(s);