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 843609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:09:21+00:00 2026-05-15T06:09:21+00:00

Why C++ compiler gives this error? Why i can access lol() from B, but

  • 0

Why C++ compiler gives this error? Why i can access lol() from B, but can not access rofl() [without parameters]. Where is the catch?

class A
{
public:
   void lol(void) {}
   void rofl(void) { return rofl(0);}
   virtual void rofl(int x) {}
};

class B : public A
{
public:
   virtual void rofl(int x) {}
};

int _tmain(int argc, _TCHAR* argv[])
{
    A a;
   a.lol();
   a.rofl(1);
   a.rofl();

   B  b;
   b.lol();
   b.rofl(1);    
   b.rofl(); //ERROR -> B::rofl function does not take 0 arguments


   return 0;
}
  • 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-15T06:09:22+00:00Added an answer on May 15, 2026 at 6:09 am

    The B::rofl(int) ‘hides’ the A::rofl(). In order to have A‘s rofl overloads, you should declare B to be using A::rofl;.

    class B : public A {
    public: 
        using A::rofl;
        ...
    };
    

    This is a wise move of C++: it warns you that you probably also need to override the A::rofl() method in B. Either you do that, or you explicitly declare that you use A‘s other overloads.

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

Sidebar

Related Questions

In C++ the following code gives a compiler error: void destruct1 (int * item)
Take the method System.Windows.Forms.Control.Invoke(Delegate method) Why does this give a compile time error: string
When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that
Upcasting is allowed in Java, however downcasting gives a compile error. The compile error
Compiler error CS0283 indicates that only the basic POD types (as well as strings,
What compiler (I'm using gcj 4.x) options should I use to generate an exe
My compiler behaves oddly when I try to pass a fixed-size array to a
I was given a C++ project that was compiled using MS Visual Studio .net
I'm generating compiled getter methods at runtime for a given member. Right now, my
Given a property: <property name=classes value=com.package.Class1,com.package.Class2 /> I'm trying to compile only the classes

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.