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;
}
static void show(){
a++;
cout<<a;
}
};
class B: public A
{
public:
};
int main(int argc, char const *argv[])
{
B b;
b.show();
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
A(){
a = 0;
}
static void show(){
a++;
cout<<a;
}
};
class B: public A
{
public:
};
int main(int argc, char const *argv[])
{
B b;
b.show();
return 0;
}
A. 1
B. 0
C. Segmentation fault
D. Error
Answer: Option D
Join The Discussion