![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
いろいろなテクニック.Nucleo と DISCO-F746 用.
Dependencies: Array_Matrix mbed
Diff: PolyMorphism.hpp
- Revision:
- 1:bbb9f0c3e523
- Parent:
- 0:bb939e0bc6e2
--- a/PolyMorphism.hpp Sun Oct 15 11:41:48 2017 +0000 +++ b/PolyMorphism.hpp Wed Apr 10 06:32:33 2019 +0000 @@ -10,21 +10,21 @@ { public: Base() {} - virtual void Execute() { printf("Base class\r\n"); } + virtual void Execute() { printf(" Base class\r\n"); } }; class Derived1 : public Base { public: Derived1() {} - virtual void Execute() { printf("Derived1 class\r\n"); } + virtual void Execute() { printf(" Derived1 class\r\n"); } }; class Derived2 : public Base { public: Derived2() {} - virtual void Execute() { printf("Derived2 class\r\n"); } + virtual void Execute() { printf(" Derived2 class\r\n"); } }; void Print(Base *obj) { obj->Execute(); } @@ -36,12 +36,12 @@ Derived2 drv2; // 例 1 - printf("\r\n"); + printf("例 1:\r\n"); Base *func[3] = { &base, &drv1, &drv2 }; for (int n=0; n<3; n++) func[n]->Execute(); // 例 2 - printf("\r\n"); + printf("例 2:\r\n"); Base *ptr; ptr = &drv2; ptr->Execute(); @@ -50,6 +50,6 @@ ptr->Execute(); // 例 3 - printf("\r\n"); + printf("例 3:\r\n"); Print(&drv2); } \ No newline at end of file