Open In App

C++ | Virtual Functions | Question 6

Last Updated : 28 Jun, 2021
Like Article
Like
Save
Share
Report

Predict the output of following program.




#include<iostream>
using namespace std;
class Base
{
public:
    virtual void show() = 0;
};
  
class Derived : public Base { };
  
int main(void)
{
    Derived q;
    return 0;
}


(A) Compiler Error: there cannot be an empty derived class
(B) Compiler Error: Derived is abstract
(C) No compiler Error


Answer: (B)

Explanation: If we don’t override the pure virtual function in derived class, then derived class also becomes abstract class.


Quiz of this Question


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads