---
title: "Access overridden members from derived class"
subject: "Object Oriented Programming"
chapter: 6
key: "semester_3/object_oriented_programming:access-overridden-members"
source: https://www.bctengineer.com/q/semester_3/object_oriented_programming/access-overridden-members
site: BCT Engineering
---

# Access overridden members from derived class

Object Oriented Programming · Chapter 6: Inheritance

- Asked in: 2073 Shrawan, 5 marks; 2068 Chaitra, 2 marks (asked 2 times)
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/object_oriented_programming/access-overridden-members
- Whole chapter: https://www.bctengineer.com/md/semester_3/object_oriented_programming/chapter-6

## Question

What do you mean by function overriding? How can we access overridden members of the base class from a member function in the derived class? Explain with example.

## Answer

**Function overriding** is redefining a member function of the base class in the derived class with the same name, return type and parameter list. When the function is called with a derived class object, the derived version is executed and the base version is hidden.

**Accessing the overridden base member:** use the **scope resolution operator** `::` with the base class name.
- Inside a derived member function: `Base::display();`
- From outside, with a derived object: `d.Base::display();`

```cpp
#include <iostream>
using namespace std;

class Base {
public:
    void display() { cout << "Base display" << endl; }
};

class Derived : public Base {
public:
    void display() {                   // overrides Base::display()
        cout << "Derived display" << endl;
        Base::display();               // call the overridden base version
    }
};

int main() {
    Derived d;
    d.display();          // Derived version, which also calls Base's
    d.Base::display();    // directly call the hidden base version
    return 0;
}
```

**Output:**

```text
Derived display
Base display
Base display
```

Without `Base::`, the call `display()` inside `Derived::display()` would call itself recursively. The `Base::` prefix tells the compiler which class's function to use.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is function overriding?
   A. Two functions with different parameters in one class
   B. Deleting a base function
   C. Redefining a base function in the derived class with the same signature
   D. Calling a function twice
   Answer: C. The derived class provides its own version with the same name, return type and parameters. (Key point: Definition)

2. How do you call the overridden base version from a derived member function?
   A. this->display()
   B. Use Base::display()
   C. Use ::display()
   D. super.display()
   Answer: B. The scope resolution operator with the base class name selects the base version. (Key point: Access method)

3. How can main() call Base's display on a Derived object d?
   A. d.display()
   B. Base.d.display()
   C. d->Base()
   D. d.Base::display()
   Answer: D. d.Base::display() names the hidden base version explicitly. (Key point: Outside call)

4. What happens if Derived::display() calls display() without Base::?
   A. It calls itself recursively
   B. It calls Base::display()
   C. Compile error always
   D. It does nothing
   Answer: A. The unqualified name finds Derived::display itself, causing recursion. (Key point: Recursion)

## Related in Object Oriented Programming

- [Member function overriding with virtual function](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Avirtual-member-override-reason) — Object Oriented Programming, chapter 7
- [Member function as friend of another class](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Amember-function-friend-of-other-class) — Object Oriented Programming, chapter 4
- [Static data member and member function](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Astatic-member-function) — Object Oriented Programming, chapter 4, asked 3×
- [Function overriding versus overloading](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Afunction-overriding-vs-overloading) — Object Oriented Programming, chapter 6, asked 2×
- [Function overriding and how to resolve it](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Afunction-overriding-resolve) — Object Oriented Programming, chapter 6
- [Manager derived from person and employee](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Amanager-person-employee) — Object Oriented Programming, chapter 6

## Related in other subjects

- [Sending structure members to a function](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astructure-members-to-function) — Computer Programming, chapter 8
- [Structure vs array; accessing members](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astructure-vs-array-access-members) — Computer Programming, chapter 8
- [Video rental shop class diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Avideo-rental-class-diagram) — Object Oriented Analysis and Design, chapter 2
- [Truss joint B: temperature and vertical members long](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Atruss-defl-b-temp-lackfit-2073) — Theory of Structures I, chapter 3, asked 2×
