Examveda

What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A{
	float d;
   public:
	virtual void func(){
		cout<<"Hello this is class A\n";
	}
};
 
class B: public A{
	int a = 15;
public:
	void func(){
		cout<<"Hello this is class B\n";
	}
};
 
int main(int argc, char const *argv[])
{
	B b;
	b.func();
	return 0;
}

A. Hello this is class B

B. Hello this is class A

C. Error

D. Segmentation fault

Answer: Option A


Join The Discussion

Related Questions on Inheritance in C plus plus