Examveda

What will be the output of the following C++ code?
#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:
 
};
 
int main(int argc, char const *argv[])
{
	B b;
	b.show();
	return 0;
}

A. Error

B. Segmentation fault

C. a: 1

D. a: 0

Answer: Option A


Join The Discussion

Related Questions on Inheritance in C plus plus