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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:50:13+00:00 2026-05-20T04:50:13+00:00

I faced a problem recently with a 3rd party library which generates classes from

  • 0

I faced a problem recently with a 3rd party library which generates classes from a xml. Here is a gist of it:

class B;
class A
{
    void doSomething();
    friend class B; 
};

class B
{
    void doSomething();
    void doSomethingMore()
    {
        doSomething();
    }
};

The compiler flags call to the function doSomething() as ambiguous and flags it as an compiler error. It is easy to understand why it gives the error.Class B being friend of class A, every member of class B has access to all the members of class A. Renaming of the either of functions resolved my problem but it got me thinking that shouldn’t in this case the compiler should give a priority to the class’s own member function over the function in another class of which it is a friend?

Note: I will update the compiler version details tomorrow..Need to check the exact version details at the workplace. I guess i should have got them in first place..:(

[Problem Update & Resolution]
I checked out again with a small sample program and my bad the problem is not with the ambiguity due to friend functions. The 3rd party library internally generates a function with the same signature and inside the same class which causes the ambiguity. Thanks for the replies, at least my misconception got corrected 🙂

  • 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-20T04:50:14+00:00Added an answer on May 20, 2026 at 4:50 am

    There is no ambiguity. The function called in A requires an A instance. The function called in B requires a B instance.

    doSomethingMore is called on a B instance and therefore the function that gets called is the one in B.

    You seem to have misunderstood friendship. All it means is that, in this case, given an instance of A, member functions of B can call the A::doSomething() function or do anything else in A that has private access.

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

Sidebar

Related Questions

I've recently faced a problem involving passing data (small amount), from a page to
Recently I've faced such problem. I'm working on the application, in which logging is
I recently faced a problem of presenting the output of simple genetic algorithm that
We have recently been faced with the problem of porting our C++ framework to
I had a really huge problem recently which took me a lot of time
I recently faced a problem about combining unit tests and doctests in Python. I
I have faced this problem quite often during the last couple of months, during
I am currently faced with a difficult sorting problem. I have a collection of
Today we faced a quite simple problem that were made even simpler by the
I face a problem when I try to get value from primary table in

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.