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
{
public:

   virtual void setOn() = 0;

   virtual void setOff() = 0;
};

Now, class B is also abstract:

class B
{
public:

   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?

1 comments

@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

32 Answered Questions

21 Answered Questions

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

6 Answered Questions

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

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

10 Answered Questions

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
  • 1892478 View
  • 4253 Score
  • 1 Answer
  • Tags:   c++ c++-faq

17 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