inheritance - Abstract class and pure method C++ -
i've read in book stephen prata - "c++ primer plus vi edition" in abstract class can write definition of pure method. understood can write example void pure() = 0
, can make definition of method in class. thought = 0
make class abstract , if make class inheriting class don't have overwrite (i don't know if word "overwrite" right, meant wan't hide method basic class writing method same name in secondary class).
i checked in compiler , warning "it has no overrider". if have overwrite pure virtual method (with definition in abstract class) in secondary class how can use definition basic class? useless?
are looking this:
class abstract { public: virtual void f() = 0; }; // pure virtual function can still defined. // has defined out-of-class. void abstract::f() { // } class concrete : public abstract { public: void f() { abstract::f(); // call base class implementation // more } };
Comments
Post a Comment