Examveda

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

A. Constructor of class A
Constructor of class B

B. Constructor of class A

C. Constructor of class B

D. Constructor of class B
Constructor of class A

Answer: Option A


Join The Discussion

Related Questions on Inheritance in C plus plus