C++ | Virtual Functions | Question 7

filter_none

edit
close

play_arrow

link
brightness_4
code

#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;
}

chevron_right


(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

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up