Derived Class

Hi,

I am a newbie and unable to clearly understand how the classes derived from an abstract base class work. My question is :


Last edited on
closed account (3hM2Nwbp)
So long as the derived class isn't abstract, and you provide a visible constructor, then clients will be able to instantiate your class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

class Abstract
{
  public:
   virtual void doSomething(void) = 0;
};

class Derived
 : public Abstract
{
  public:
   virtual void doSomething(void) { } // <-- Should have named it "doNothing"
};

int main()
{
  Derived instance;
  return 0;
}
In short I need to override the pure virtual function of the abstract base class with some concrete member function right?
closed account (3hM2Nwbp)
You'll need to override every pure virtual method of the base(s) if you want to instantiate that class.
Last edited on
Topic archived. No new replies allowed.