0

What is the output of the following C++ program?

#include<stdio.h>

 

[gamipress_button type=”submit”  label=”Run Code Online” onclick=”window.open(‘https://coderseditor.com’,’_blank’)”]

#include<iostream>
using namespace std;
 class base
{
public:
 virtual void show() { cout<<" In Base \n"; }
};
 class derived: public base
{
 int x;
public:
 void show() { cout<<"In derived \n"; }
 derived() { x = 10; }
 int getX() const { return x;}
};
 int main()
{
 derived d;
 base *bp = &d;
 bp->show();
 cout << bp->getX();
 return 0;
}

Studently Answered question October 10, 2022