ExamVeda
Login
Home
Inheritance in C plus plus
?

What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class Mammal
{
   public:
	Mammal(){
		cout<<"I'm a Mammal\n";
	}
	~Mammal(){}
};
 
class Human: public Mammal
{
   public:
	Human(){
		cout<<"I'm a Human\n";
	}
	~Human(){}
};
 
class Male: public Human
{
   public:
	Male(){
		cout<<"I'm a Male\n";
	}
	~Male(){}
};
 
class Female: public Human
{
   public:
	Female(){
		cout<<"I'm a Female\n";
	}
	~Female(){}
};
 
int main(int argc, char const *argv[])
{
	Male M;
	return 0;
}

Answer & Solution
Correct Answer: Option A
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.