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.
以下旧式演员表的命名演员表等价物是什么?
const string *ps; void *pv; pv = (void*)ps; // <--- this
是pv = static_cast<void*>(const_cast<string*>(ps));吗?
pv = static_cast<void*>(const_cast<string*>(ps));
pv = const_cast<string *>(ps);
足够好 -可以从任何(非限定)数据(对象)指针类型void *隐式分配。
void *
(当然,出于同样的原因,直接分配到const void * 没有任何转换也可以。)
const void *