ExamVeda
Login
Home
Inheritance in C plus plus
?

What happens if the following C++ program is compiled?
#include <iostream>
#include <string>
using namespace std;
class A
{
	int a;
   public: 
	A(){
		a = 0;
	}
	void show(){
		a++;
		cout<<"a: "<<a<<endl;
	}
};
 
class B: private A
{
   public:
	void show(){
		show();
	}
};
 
int main(int argc, char const *argv[])
{
	B b;
	b.show();
	return 0;
}

Answer & Solution
Correct Answer: Option B
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.