【发布时间】:2011-08-27 02:40:29
【问题描述】:
对于参数为 void* 的方法,是 C++ 使用 static/reinterpret_cast 进行转换,还是这里有不同的机制?
void foo(void* p)
{
// ... use p by casting it back to Base first, using static/reinterpret cast
}
Base* base(new Derived);
foo(base); // at this exact line, is there a static/reinterpret_cast going on under the covers?
我之所以这么问,是因为一方面标准说对于 c 风格的演员表,C++ 会去尝试 C++ 演员表(静态、重新解释、常量),直到找到有效的东西。但是,对于调用带有 void* 参数的方法时会发生什么,我找不到合理的解释。表面上没有演员表,那会发生什么?
【问题讨论】:
标签: c++