// ( c19.C ) // 純粋仮想関数の実装クラスの注意 // #include // クラス階層中のどこかで実装しておけばよい // 派生クラスの最後で行う場合 /* class Base { protected: int color ; public: virtual void show() = 0 ; // 純粋仮想関数 } ; class Abstruct: public Base { } ; class Point: public Abstruct { public: Point() { color = 2 ; } // ここで実装した void show() { cout << "Color = " << color << endl ; } } ; */ // 派生クラスの途中で行う場合 class Base { protected: int color ; public: virtual void show() = 0 ; } ; class Abstruct: public Base { public: // ここで実装した void show() { cout << "Color = " << color << endl ; } } ; class Point: public Abstruct { public: Point() { color = 2 ; } } ; main() { Point p ; p.show() ; }