“warning: use of old-style cast” in g++ [duplicate]
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: When should static_cast, dynamic_cast and reinterpret_cast be used? With this C++ code, char* a = (char*) b; I got warning warning: use of old-style cast . What would be the new-style cast? 回答1: reinterpret_cast , static_cast , dynamic_cast and const_cast are the c++ cast alternatives. const_cast to remove const/volatile from a const variable. dynamic_cast to perform runtime validity checks when casting in between polymorphic types static_cast to perform e.g up/down-cast in a inheritance hierarchy, but with no runtime