您的位置:首页 > 编程语言 > C语言/C++

Class Hierarchies(Chapter 15 of The C++ Programming Language)

2010-08-08 14:39 886 查看
[1] Use ordinary multiple inheritance to express a union of features; [2] Use multiple inheritance to separate implementation details from an interface;[3] Use a virtual base to represent something common to some, but not all, classes in a hierarchy;[4] Avoid explicit type conversion (casts); [5] Use dynamic_cast where class hierarchy navigation is unavoidable; [6] Prefer dynamic_cast over typeid;[7] Prefer private to protected ;[8] Don’t declare data members protected; [9] If a class defines operator delete(), it should have a virtual destructor;[10] Don’t call virtual functions during construction or destruction;[11] Use explicit qualification for resolution of member names sparingly and preferably use it in overriding functions;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: