Vidyalelo
C++ Programming · Q64

Inheritance in C++

Programming · C++ Programming · question 64

Q64

What will be the output of the following C++ code? #include #include using namespace std; class A float d; public: int a; void change(int i) a = i; void value_of_a() cout<<a; ; class B: public A int a = 15; public: void print() cout<<a; ; int main(int argc, char const *argv[]) B b; b.change(10); b.print(); b.value_of_a(); return 0;

A.
1010
B.
1510
Answer
C.
1515
D.
5110

Answer: Option B

Solution

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