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

34 Answered Questions

10 Answered Questions

6 Answered Questions

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

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

21 Answered Questions

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

1 Answered Questions

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

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

23 Answered Questions

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

18 Answered Questions

[SOLVED] C++ Singleton design pattern

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