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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:28:59+00:00 2026-05-25T19:28:59+00:00

I need to determine whether an element is the same as the one I’m

  • 0

I need to determine whether an element is the same as the one I’m passing by reference.
In the function Belongs I need to compare equality between d is and an element of a stored in a dynamic list:

struct Nodo{ Dominio dominio; Rando rango; Nodo* next; }; 
typedef Nodo* ptrNodo; 
ptrNodo pri; 

template<class Dominio, class Rango>
bool DicListas<Dominio,Rango>::Belongs(const Dominio &d)
{
  bool retorno = false;
  if(!EsVacia())
  {
    ptrNodo aux=pri;

    while(aux!=NULL)
    {
      if(aux->dominio==d)//-------> THIS CLASS DOESN'T KNOW HOW TO COMPARE THE TYPE DOMINIO.
      {
        retorno = aux->isDef;
      }
      aux = aux->sig;
    }
  }
  return retorno;
}
  • 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-25T19:28:59+00:00Added an answer on May 25, 2026 at 7:28 pm

    Whatever type argument you provide for the type parameter Dominio, you’ve to overload operator== for that type.

    Suppose, you write this:

    DicListas<A,B>  obj;
    obj.Belongs(A());
    

    then you’ve to overload operator== for the type A as:

    class A
    {
     public:
        bool operator == (const A &a) const
        {
           //compare this and a.. and return true or false
        }
    };
    

    Also note that it should be public if it’s a member function, and better make it const function as well, so that you can compare const objects of type A.

    Instead of making it member function, you can make operator== a non-member function as well:

    bool operator == (const A &left, const A & right)
    {
         //compare left and right.. and return true or false
    }
    

    I would prefer the latter.

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

Sidebar

Related Questions

I need to determine whether or not two sets contains exactly the same elements.
I need to determine whether a string matches one substring, but not another. For
I need to determine whether a selected UIColor (picked by the user) is dark
I need to determine whether an HTTP request was an HTTP/1.0 or an HTTP/1.1
I need to programatically determine whether .NET 3.5 is installed. I thought it would
I need a way to determine whether the computer running my program is joined
Executive summary: I need a way to determine whether a Windows process I've spawned
I need to determine whether there is a resource file for the given CultureInfo
I need to determine whether a string ( sourceString ) contains another string (
I need to determine whether the ActivePresentation is 97-2003 or 2007 format. I really

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.