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

  • SEARCH
  • Home
  • 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 6362529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:55:12+00:00 2026-05-24T23:55:12+00:00

I know these 3 concepts. But I remember there was another definition: Say a

  • 0

I know these 3 concepts.

But I remember there was another definition:
Say a base class has 2 virtual methods: Foo() and Foo(int a).
Is there any rule that when a derived class overrides Foo(int a) has to override all other overloads of Foo ?

Was it in Java? I believe it dosn’t exist in C#.

Thanks

  • 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-05-24T23:55:12+00:00Added an answer on May 24, 2026 at 11:55 pm

    C++:

    What you are referring to is name hiding in C++. When you have a class with overrided methods, and you extend this class an override one of the overrided methods, you need to override all the overloaded methods. If not, calls to non-overridden overloaded in the extended class won’t work.

    For example:

    class Base {
        public:
            virtual void A (int);
            virtual void A (int, int);
    };
    void Base::A(int i) {
        std::cout << “Hi\n”;
    }
    void Base::A (int i, int j) {
        std::cout << “Bye!!\n”;
    }
    

    Suppose you only override one of the methods:

    class Sub: public Base {
        public:
            void A(int);
    };
    void Sub::A(int i) {
        std::cout << “Hey, La!\n”;
    }
    void main () {
        Sub a;
        a.A(1);
        a.A(1, 1);//won't compile
    }
    

    The second call won’t work, as A(int, int) is not visible. This is name hiding.
    If you want to circumvent this, you can use the using keyword as follows:

    class Sub: public Base {
        public:
            void A(int);
            using Base::A;
    };
    void Sub::A(int i) {
        std::cout << “Hey, La!\n”;
    }
    void main () {
        Sub a;
        a.A(1);
        a.A(1, 1);//will compile
    }
    

    Java:

    Java doesn’t have such a concept though. You can try this out yourself. Note that all Java methods are virtual by default as per virtual C++ methods.

    public class Base {
        public void A() {
            System.out.println("Hi");
        }
        public void A(int i, int j) {
            System.out.println("Bye");
        }
    }
    
    public class Sub extends Base {
        public void A() {
            System.out.println("Hey, La!");
        }
    }
    
    public class Test {
        public static void main(String[] args) {
            Sub a = new Sub();
            a.A();
            a.A(1, 1);//perfectly fine
        }
    }
    

    Aside:

    I hope you’re not referring to extending an abstract class- if you extend an abstract class, you need to override all abstract methods else your class has to be declared abstract.

    All methods of an implemented interface need to be implemented though.

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

Sidebar

Related Questions

I know how I use these terms, but I'm wondering if there are accepted
I know that probably there is no concept of scope for macros, but please
My client has PHP running on an IIS server, I know these vti_conf files
I know there is a lot of talk about BPM these days and I
I know there are already a lot of articles about this concept but my
I used to use mysql, and in mysql database hold tables, but these concepts
I am new to these concepts. But as i am going deeper in threading
anyone know if these are available?
Does anyone know what these error's mean? I get this when I click a
I want to swap two integers, and I want to know which of these

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.