2016年7月4日

C++ 抽象类二(抽象类的基本语法)

摘要: //抽象类的基本语法 #include using namespace std; /* 有关多继承的说明 被实际开发经验抛弃的多继承 工程开发中真正意义上的多继承是几乎不被使用的 多重继承带来的代码复杂性远多于其带来的便利 多重继承对代码维护性上的影响是灾难性的 在设计方法上,任何多继承都可以用单继承代替 绝大多数面向对象语言都不支持多继承 绝大多数面向对象语言都支持接口的概念 C++中没有... 阅读全文

posted @ 2016-07-04 16:52 寒魔影 阅读(580) 评论(0) 推荐(0)

C++ 抽象类一(多继承与赋值兼容性原则)

摘要: //多继承与赋值兼容性原则 #include using namespace std; class Point{ public: Point(){ a = 1; b = 2; } int a; int b; }; class PointA { public: PointA(){ c = 3; } ... 阅读全文

posted @ 2016-07-04 11:02 寒魔影 阅读(1047) 评论(0) 推荐(0)

C++ 类的多态五(多态的语法本质分析)

摘要: //多态的语法本质分析 #include using namespace std; /* 三种易混淆的多态场景 */ class Point{ public: Point(int b=0){ this->b = b; } virtual void Print(){ cout Print(); //此时p3->Print();会... 阅读全文

posted @ 2016-07-04 09:55 寒魔影 阅读(422) 评论(0) 推荐(0)

导航