摘要: 先看下面的例子: 1 enum MyColor 2 { 3 RED, 4 GREEN, 5 BLUE, 6 }; 7 8 class Shape 9 {10 public:11 void virtual Draw(MyColor color = RED) const = 0;12 };13 14 class Rectangle: public Shape15 {16 public:17 void Draw(MyColor color = GREEN) const18 {19 cout Draw() = "; // ?38 ... 阅读全文
posted @ 2014-03-13 23:51 Jerry19880126 阅读(1045) 评论(0) 推荐(0) 编辑
摘要: 这个条款的内容很简单,见下面的示例: 1 class BaseClass 2 { 3 public: 4 void NonVirtualFunction() 5 { 6 cout NonVirtualFunction(); // 输出BaseClass::NonVirtualFunction25 dp->NonVirtualFunction(); // 输出DerivedClass::NonVirtualFunction26 }从输出结果可以看到一个有趣的现象,那就是两者都是通过相同的对象d调用成员函数NonVirutalFunction,但显示结果却不... 阅读全文
posted @ 2014-03-13 00:03 Jerry19880126 阅读(1164) 评论(0) 推荐(0) 编辑