Vidyalelo
C++ Programming · Q45

Inheritance in C++

Programming · C++ Programming · question 45

Q45

What will be the output of the following C++ code? #include #include using namespace std; class A int a; public: A() a = 0; void show() a++; cout<<"a: "<<a<<endl; ; class B: public A public: ; int main(int argc, char const *argv[]) B b; b.show(); return 0;

A.
a: 1
Answer
B.
a: 0
C.
Error
D.
Segmentation fault

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board