开发者

Differece between Static and reinerpret cast [duplicate]

开发者 https://www.devze.com 2023-03-12 12:34 出处:网络
This question already has answers here: 开发者_如何学CClosed 11 years ago. Possible Duplicate: When should static_cast, dynamic_cast and reinterpret_cast be used?
This question already has answers here: 开发者_如何学C Closed 11 years ago.

Possible Duplicate:

When should static_cast, dynamic_cast and reinterpret_cast be used?

class b
{
}
class d :public b
{
}

int main
{
 d* d_p = new d();
 b* b_p = static_cast<base*>(d_p);

 b* b_p = reinterpret_cast<base*>(d_p); // any difference will it make
 return 0;
}

So in the above example does static and reinterpret cast make any difference functionaly etc..? for me both are same in this scenario.


Yes, there will be a difference. You should check here

0

精彩评论

暂无评论...
验证码 换一张
取 消