By Wballer3

2018-06-13 14:03:14 8 Comments

I have a class which has a pure virtual function declared, like this:

class A : public virtual B

   virtual void setOn() = 0;

   virtual void setOff() = 0;

Now, class B is also abstract:

class B

   virtual const ElementId& getElementId() const = 0;

   virtual const std::string& getName() const = 0;

   virtual ~B();


My question is how class A can be valid, since it does not provide the implementation of the pure virtual methods in class B?


@Sombrero Chicken 2018-06-13 14:08:03

A class that inherits from an abstract class does not have to implement the pure virtual methods. Not doing so it becomes an abstract class itself which means in this case that A is also an abstract class regardless of other pure virtual methods declared in A.

Related Questions

Sponsored Content

21 Answered Questions

[SOLVED] What is the "-->" operator in C++?

23 Answered Questions

[SOLVED] Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition

1 Answered Questions

[SOLVED] The Definitive C++ Book Guide and List

  • 2008-12-23 05:23:56
  • grepsedawk
  • 1999051 View
  • 4252 Score
  • 1 Answer
  • Tags:   c++ c++-faq

33 Answered Questions

18 Answered Questions

[SOLVED] C++ Singleton design pattern

6 Answered Questions

[SOLVED] What is meant with "const" at end of function declaration?

  • 2010-06-29 13:31:02
  • aPoC
  • 389719 View
  • 429 Score
  • 6 Answer
  • Tags:   c++ const

5 Answered Questions

[SOLVED] How do I use arrays in C++?

5 Answered Questions

[SOLVED] Are abstract methods and pure virtual functions the same thing?

Sponsored Content