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

The Archive Base Latest Questions

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

Before asking, I had refer to this older question . But I have still

  • 0

Before asking, I had refer to this older question. But I have still queries.

struct B1 {
  virtual void fun () = 0;
};
struct B2 {
  void fun () { cout<<"B2::fun()\n"; }
  void fun (int i) {}
};
struct D : B1, B2 {
  using B2::fun;  // This line doesn't help
};

int main ()
{
  B1 *pB1 = new D;  // Error: cannot allocate 'D' because 'B1::fun()' is abstract
  pB1->fun();
}
  1. Any reason for C++ standard not accepting, inherited member functions to resolve pure virtual mechanism ?
  2. Why using keyword doesn’t help resolving this error ? (compiler: linux-64 g++)
  3. Which function is used for using keyword, B2::fun() or B2::fun(int) ? (there is no ambiguity for that line)
  • 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-21T06:45:04+00:00Added an answer on May 21, 2026 at 6:45 am

    Which function is used for using keyword, B2::fun() or B2::fun(int) ? (there is no
    ambiguity for
    that line )

    From ISO/IEC 14882:2003(E) 7.3.3.12

    When a using-declaration brings names from a base class into a derived class scope, member functions in the derived class override and/or hide member functions with the same name and parameter types in a base class (rather than conflicting).

    [Example:
        struct B { 
            virtual void f(int);
            virtual void f(char); 
            void g(int); 
            void h(int);
        };
    
        struct D : B { 
            using B::f;
            void f(int);   // OK: D::f(int) overrides B::f(int);
    
            using B::g; 
            void g(char);  // OK
    
            using B::h; 
            void h(int);   // OK: D::h(int) hides B::h(int)
        };
    
        void k(D* p) {
            p->f(1);    //calls  D::f(int)
            p->f(’a’);  //calls  B::f(char)  // Notice the call being resolved
            p->g(1);    //calls  B::g(int)
            p->g(’a’);  //calls  D::g(char)
        }
    
    — end example] 
    

    [Note: two using-declarations may introduce functions with
    the same name and the same parameter types. If, for a call to an unqualified
    function name, function overload resolution selects the functions introduced
    by such using-declarations, the function call is ill-formed. ]

    So, in the example you provided there is no ambiguity at all. Depending up on the parameter passed, call to a method can be decided.

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

Sidebar

Related Questions

Ok, I have done plenty of research on this topic before asking the question,
Before asking my question, let me explain the context. CONTEXT: I have a web
I searched before asking this question. I didn't find an answer probably because I
I searched SO before asking this question, I am completely new to this and
I have a question regarding n-layer architecture. I thought long and hard before asking
I find it odd that I couldn't find anyone asking about this before. But
I tried to search a bit before asking but I really had no idea
Before I asked this question I had a look through the search results for
The reason I am asking this question is because I have landed my first
Before asking the question let me preface with the fact that I am new

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.