C++ | Inheritance | Question 9
#include<iostream> using namespace std; class Base { public: int fun() { cout << "Base::fun() called"; } int fun(int i) { cout << "Base::fun(int i) called"; } }; class Derived: public Base { public: int fun() { cout << "Derived::fun() called"; } }; int main() { Derived d; d.Base::fun(5); return 0; } |
chevron_right
filter_none
(A) Compiler Error
(B) Base::fun(int i) called
Answer: (B)
Explanation: We can access base class functions using scope resolution operator even if they are made hidden by a derived class function.
Quiz of this Question
Recommended Posts:
- C++ | Inheritance | Question 12
- C++ | Inheritance | Question 3
- C++ | Inheritance | Question 4
- C++ | Inheritance | Question 5
- C++ | Inheritance | Question 14
- C++ | Inheritance | Question 1
- C++ | Inheritance | Question 2
- C++ | Inheritance | Question 8
- C++ | Inheritance | Question 13
- C++ | Inheritance | Question 10
- C++ | Inheritance | Question 11
- C++ | Inheritance | Question 6
- C++ | Inheritance | Question 7
- Java | Inheritance | Question 9
- Java | Inheritance | Question 7



