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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:53:27+00:00 2026-05-24T06:53:27+00:00

Guys I have some silly struct let’s call it X and I also have

  • 0

Guys I have some silly struct let’s call it X and I also have a fnc (not a member of it) returning a pointer to this struct so it looks like so:

    struct  X
    {
bool operator==(const X* right)
{
//...
}
};

X* get(X* another)
{
//...
}

I also have line in code which ‘tries’ to compare pointers to those structs but the real intention is to compare those structs pointed to:

if (get(a) == get(b))//here obviously I have two pointers returned to be compared
{
//...
}

I also defined member of X operator==(const X* right) which suppose to work in situations aforementioned but for reason I do not understand it doesn’t. How to make it work (I CANNOT change the line if (get(a) == get(b)) and also get MUST return pointer).

  • 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-24T06:53:27+00:00Added an answer on May 24, 2026 at 6:53 am

    You cannot change the way pointers are compared. You must either change the syntax of the if statement, or change get() to return a reference instead of pointer. Any other solution is going to be quite hacky.

    If you truly must live with those restrictions, I would suggest changing get() to return some kind of specialized smart pointer to encapsulate this inconsistent behavior you want, with overloaded operator ->() and overloaded operator ==(). I swear though, this is really just asking for trouble, and I think you’re still better to fight whatever power doesn’t allow you to change the if() statement.

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

Sidebar

Related Questions

I hope some of you guys can help me with this problem.... I have
Let me start off by clarifying that(before you guys dismiss me), this is not
Ok guys just a small game: I have some specifications for a project. At
Thus far you guys have been wildly helpful with me getting this little ditty
guys i have arrays in which i have to match this kind of text
I'm new to Cocoa and xCode, but not programming though. I have created some
Hi guys I have some networking issues with Hadoop cluster, and I think I
I have some guys here who have code that needs to be compiled with
Hey guys, I have some code that I found that I would rather use
[I have some code to create a JSON array. In this code 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.