主要参考:http://blog.csdn.net/querw/article/details/7387594

http://www.cnblogs.com/jerry19880126/archive/2012/08/14/2638192.html

http://www.cnblogs.com/ider/archive/2011/07/30/cpp_cast_operator_part3.html

http://bbs.csdn.net/topics/390249118


关键点:

1.reinterpret_cast: reinterpret“重新解释”内存类型 

“重新解释了数据的比特模型,并没有进行二进制的转换”

static_cast  : 编译时强制转换,进行安全性检查、截断、指针偏移;

2.注意转换是长对短,下对上;还是短对长,上对下转


比如

Struct CBaseX
{
  int x;
}
Struct CBaseY
{
  int y;
}
Struct CDerived:CBaseX,CBaseY{}
进行static_cast<CBaseY*>(&d),//此时进行了指针的偏移,如下图所示,偏移了baseX的四个字节
//如果是reinterpret_cast则不会进行偏移。


wKioL1VXd-yy7CFdAAEI-VgA268544.jpg