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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:51:24+00:00 2026-06-12T17:51:24+00:00

I realize I’m stupid so please go easy on me. Yes this is an

  • 0

I realize I’m stupid so please go easy on me. Yes this is an assignment, but I want to understand what I’m doing wrong, not just the answer.

I’m trying to write an operator== and an operator!= function for an iterator on a binary search tree in the BSTIterator class template.

Given (all in the same class template):

private: 

BSTNode<Data>* curr;

...

bool operator==(BSTIterator<Data> const & other) const {
  (here's where I do my magic)
}

Same setup for operator!=.

I write for == …

  return (&curr == other);

I don’t think I need the parentheses but anyway … here’s what I have for !=

  return !(&curr == other);

My compiler has a problem with != but not apparently ==.

It spit out a lot of gobbledy gook but, as far as I can tell, the relevant part is:

No match for ‘operator!=’ in ‘&((const
BSTIterator*)this)->BSTIterator::curr != other’

and it references the line that says return !(&curr == other);

I think at first the compiler didn’t like my operator== function either but I see no reference to it now. Why would it like one and not the other when they are basically the same except for the ! ?

Please let me know if I need to include more information.

  • 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-06-12T17:51:25+00:00Added an answer on June 12, 2026 at 5:51 pm

    As I understand from your code curr indicate the position that your iterator point to it.
    Do when you compare an instance of your iterator with another you should check if they both point to the same location. am I right? if the answer is true shouldn’t you code like this:

    bool operator==( BSTIterator<Data> const & other) const {
        return this->curr == other.curr;
    }
    bool operator!=( BSTIterator<Data> const & other) const {
        return this->curr != other.curr;
    }
    

    And about your error: your compiler say &cur is of a type( BSTNode<Data>** ) that I don’t know how to compare it with an instance of your iterator( BSTIterator<Data> ) and that’s obvious since you are defining == and != for your class and you never defined and operator for such operation, do you?

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

Sidebar

Related Questions

I realize this is fairly abstract, but I'd like to do something not unlike
I realize the following function calls are all same, but I do not understand
I realize this is a contrived example, but I want a compile check to
I realize there is a question with this title but it is not correctly
I realize this is an easy question, but despite searching I can't find anything
I realize that there are many questions similar to this one, but having looked
I realize this question has been asked and answered in the past, but I'm
I realize this is a ridiculous request, but what I'm trying to do is
I realize this is a broad topic, but I'm looking for a good primer
I realize this is kind of a long question, but I saw no other

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.