Skip to content
Related Articles

Related Articles

Improve Article

C++ | Virtual Functions | Question 7

  • Difficulty Level : Medium
  • Last Updated : 28 Jun, 2021
Geek Week




#include<iostream>
using namespace std;
  
class Base
{
public:
    virtual void show() = 0;
};
  
class Derived: public Base
{
public:
    void show() { cout<<"In Derived \n"; }
};
  
int main(void)
{
    Derived d;
    Base &br = d;
    br.show();
    return 0;
}

(A) Compiler Error in line “Base &br = d;”
(B) Empty Output
(C) In Derived


Answer: (C)

Explanation: Please refer Pure Virtual Functions and Abstract Classes in C++


Quiz of this Question

Take a step-up from those “Hello World” programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.
My Personal Notes arrow_drop_up
Recommended Articles
Page :