const_cast,static_cast,dynamic_cast,reinterpret_cast的区别
摘要:C++继承了C中的隐式和显式转换的方式。但这种转换并不是安全和严格的, 加上C++本身对象模型的复杂性,C++增加了四个显示转换的关键字。(C++是强类型语言) 经过编码测试,小结如下: const_cast:仅用于去掉完全同类型的const,volatile约束,不能含有任何其它类型的转换,若不含
阅读全文
C++ map<char *,int>
摘要:由于使用map<char *,int> 表示的是指针值到int的映射,在实际使用中经常想表示的是指针内容与int的映射,而又不想使用map<string,int>,怎么办? 可通过重载操作符实现 struct ptrCmp{ bool operator()( const char * s1, con
阅读全文
PAT 1021. Deepest Root (25)
摘要:1021. Deepest Root (25) A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you
阅读全文