There are good reasons for declaring an abstract class.
- Make a base class abstract, then you can subclass it. You can use it in polymorphism.
- Make it a "pure abstract class" by declaring its virtual methods as abstract
Then the compiler should make sure that you never instantiate a MyBaseClass by accident (it would crash as soon as you called one of the virtual methods anyway).Code:class MyBaseClass { virtual int GetSomething() = 0; virtual std::string GetName() = 0; virtual ~MyBaseClass(); };
Slarty




Reply With Quote