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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:14:04+00:00 2026-05-22T03:14:04+00:00

I have the following code: bool operator==(const Inc::CReminderItem& Item1, const Inc::CReminderItem& Item2) { bool

  • 0

I have the following code:

bool operator==(const Inc::CReminderItem& Item1, const Inc::CReminderItem& Item2)
{
    bool bDate = false, bDesc = false, bInfo = false, bWeekday = false;

    if(Item1.m_Date == Item2.m_Date)
        bDate = true;
    if(Item1.m_strDescription == Item2.m_strDescription)
        bDesc = true;
    if(Item1.m_strInfoShort == Item2.m_strInfoShort)
        bInfo = true;
    if(Item1.m_nWeekday == Item2.m_nWeekday)
        bWeekday = true;

    return(bDate && bDesc && bInfo && bWeekday);
}

bool operator!=(const Inc::CReminderItem& Item1, const Inc::CReminderItem& Item2)
{
    return !(Item1 == Item2);    // <<--- ambiguous here!
}

both operators are declared as friend operators in the class.

the error is:

error C2593: ‘operator ==’ is
ambiguous

I am not sure, why it is ambiguous O_o and how to fix this.
Any help is greatly appreciated:)

  • 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-22T03:14:05+00:00Added an answer on May 22, 2026 at 3:14 am

    First, if it is “ambiguous”, I would expect other operator== to be
    present somewhere. But it’s hard to say what any particular compiler is
    really trying to tell you with it’s error messages.

    Second, you really don’t show enough code for anyone to say what is
    wrong. There are a number of possible errors: the class where the
    friend is declared and these definitions are in different namespaces,
    the signature of the friend is subtly different, etc. If Inc is
    a namespace, these operators must be in Inc as well. Otherwise,
    you’ve declared an operator== in Inc in the friend declaration, and
    an operator== in global namespace here. Both are considered, which
    results in an ambiguity.

    (The way I usually handle this is to define a member function,
    isEqual, and have both operator== and operator!= call it. That
    way, there’s no need for the friend declaration.)

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

Sidebar

Related Questions

Say I have the following code snippet in c# static const bool DO_PERFORMANCE_CODE =
I have the following line of code: public bool dcpl_radar() { if (radar ==
Assume that we have the following code: class Program { static volatile bool flag1;
I have the following method in my code: private bool GenerateZipFile(List<FileInfo> filesToArchive, DateTime archiveDate)
I have made the following code:- class A{ bool bFlag[2]; public: A(){ for(int i
I have the following functor: class ComparatorClass { public: bool operator () (SimulatedDiskFile *
I have the following code in a class: operator string() { return format(CN(%d), _fd);
I have written a relational operator < as member of class Test bool Test::operator<(const
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section

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.