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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:57:32+00:00 2026-06-13T15:57:32+00:00

I have following code with error: (Visual Studio error:)Error 5 error C2678: binary ‘!=’

  • 0

I have following code with error:

(Visual Studio error:)Error 5 error C2678: binary ‘!=’ : no operator found which takes a left-hand operand of type ‘` Node’ (or there is no acceptable conversion)

  template <class C, class T>
    C find2 ( C first , C last, T c )
    {
        //
        while ( first != last && *first != c )
        {
            ++first;
        }

        return first;
    }

    struct Node
    {
        Node(int a ,Node* b):val(a),next(b){};
        int val;
        Node* next;
    };

    template <class T>
    struct node_wrap
    {
        T* ptr;

        node_wrap ( T* p = 0 ) : ptr ( p ) {}
        Node& operator*() const {return *ptr;}
        Node* operator->() const {return ptr;}
        node_wrap& operator++ () {ptr = ptr->next; return * this;}
        node_wrap operator++ ( int ) {node_wrap tmp = *this; ++*this; return tmp;}

        bool operator== ( const node_wrap& i ) const {return ptr == i.ptr;}
        bool operator!= ( const node_wrap& i ) const {return ptr != i.ptr;}

    };
    bool operator== ( const Node& node, int n )
    {
        return node.val == n;
    }


    int main()
    {

        Node* node1=new Node(3,NULL);
        Node* node2=new Node(4,NULL);
        node1->next = node2;
        find2 ( node_wrap<Node>(node1), node_wrap<Node>(), 3) ) ;
        delete node1;
        delete node2;
        return 0;
    }

what’s wrong with this code?

  • 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-13T15:57:33+00:00Added an answer on June 13, 2026 at 3:57 pm

    You are attempting to compare a Node with an int (this is done in the function find2 when performing *first != c).

    While you have provided an operator== for comparing a Node with an int, you haven’t provided an operator!= to do the same. If you add one, this should work.

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

Sidebar

Related Questions

I have the following code which compiles and runs fine under Visual Studio 2008
I have the following code which works in a Visual Studio 2010 WCF project.
I have added the following code in my C#.net application in visual studio 2010
I have successfully constructed something similar to the following code in visual studio 2008:
I have the following code and Visual Studio C++ reports two errors: #include windows.h
I have the following C++ code to make dll (Visual Studio 2010). class Shape
In the following code Visual Studio puts an error message on the word else.
I have the following code that needs to be ported to Visual Studio 2008.
I have following code using hibernate to throw a custom exception on error and
I have the following code however am getting the error Uncaught TypeError: Object #<addThis>

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.