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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:13:58+00:00 2026-05-15T19:13:58+00:00

Please look at the following code: #include <iostream> using namespace std; class A {

  • 0

Please look at the following code:

#include <iostream>
using namespace std;

class A {
  public:
    A() {};    
    virtual void foo(double d) { cout << d << endl; }
    virtual void foo(double d, int a) = 0;
  };

class B : public A {
  public: 
    B() {};
    virtual void foo(double d, int a) { cout << d << endl << a << endl; }  
  };

int main()
  {
  B b;
  b.foo(3.14);
  return 0;
  }

The compiler (tried g++ and visual c++ 2008) says that there’s no function like B:foo(double). The exact message of g++ is:

main.cpp:21: error: no matching function for call to ‘B::foo(double)’

It looks like the effect of hiding rule, but in my opinion the rule should not be used here, since I’m not overriding foo(double) and both foo methods are defined in base class.

I know that I can fix the problem with

using A::foo;

declaration in the derived class B.

Can you explain why the code does not compile and what rules of C++ apply here?

  • 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-15T19:13:58+00:00Added an answer on May 15, 2026 at 7:13 pm

    The hiding rule is not about overriding, it is about hiding of names. If the derived class declares a member function, this hides other base class member functions with the same name. This also happens in your case.

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

Sidebar

Ask A Question

Stats

  • Questions 519k
  • Answers 519k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well, the included script does use the target name as… May 16, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer Once is sufficient, $AddLine1-3 now holds "Safe" values May 16, 2026 at 8:26 pm
  • Editorial Team
    Editorial Team added an answer Yes you can. You will need to implement a custom… May 16, 2026 at 8:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Please take a look at following code: #include <stdio.h> #include <iostream> using namespace std;
I have the following code: #include <iostream> #include <string> void main() { std::string str;
Please look at my sourcecode. public class EntityQuery { public static Func<AdventureWork2008Container, IQueryable<SalesPerson>> selectQuery
Please have a look to the following code: <?php $nomeDominio=''; if (isset($_GET['infoDominio'])) { $nomeDominio
I have a question regarding the following code: abstract class a { public static
Have a look at the following code you are not required to read the
Please look at the following test page : sample page showing two images .
please take a look at the following website: http://www.solidcamxpress.co.uk/ If you look at it
Inorder to split the string i have used the following code. $string = -sev*yes-sev1*no-sev2*yes;
I have a templated class named check and its partial specialization, now i am

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.