Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8592491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:45:45+00:00 2026-06-11T23:45:45+00:00

I have two classes, and the methods in them are shown below; |—-AVL—-| |—–RB——|

  • 0

I have two classes, and the methods in them are shown below;

|----AVL----|     |-----RB------|
|           |     |             |
|           |     |             |
| - insert  |     | -balance    |
|           |     |             |
| - balance |     |             |
|           |     |             |
|-----------|     |-------------|

inside “insert” method of AVL, it calls “balance”.
RB inherits AVL, so I can use insert method of AVL. Now when I call RB::insert(), it calls AVL::insert() & then AVL::balance(), but I want it to call RB::balance() from AVL::insert(), when a RB object calls “insert”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:45:46+00:00Added an answer on June 11, 2026 at 11:45 pm

    This is a classic case for virtual methods: make AVL.balance virtual and override it in RB. The correct implementation will then be called depending on what type of object calls balance — it doesn’t matter that the code that calls balance will be written as part of AVL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine that I have two classes (shown below). Now imagine that I am compiling
I have two classes: JDialog and JFrame (see below). Now I want them to
I'm having trouble grasping generic methods. I have two classes that are generated (they
All -- I have these two methods in one of my classes: public static
I have two classes: Superclass and derived Subclass:Superclass. I have a generic method: public
I have two classes Foo and Bar that Bar extends Foo as below: class
I have two classes called Person and Animal that have a lot of methods
i have two classes which have some common methods like funcA(), funcB() and some
I have two classes (ClassA and ClassB) who both have two methods (compare and
I have two classes which share the identical methods and I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.