Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Iterator gives error

Iterator gives error

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpvisual-studiographicsalgorithms
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    b rad311
    wrote on last edited by
    #1

    Hi, I'm using the following code in visual studio 2008:

    std::vector< double >::iterator location;
    location=std::find(vec.begin(),vec.end(),0.);

    and I'm getting the error:

    error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::_Vector_iterator<_Ty,_Alloc>' (or there is no acceptable conversion)

    My header files are as follows (I know all these aren't necessary for this small portion of code, but the rest of my code requires the additional headers):

    #include "stdafx.h"

    #include <algorithm>
    #include <iostream>
    #include <vector>

    //#include <sstream>
    #include <fstream>
    #include <string>
    #include <ostream>

    Does anyone know how to fix this? Is it possibly a visual studio project setting :confused: Thanks!

    N 1 Reply Last reply
    0
    • B b rad311

      Hi, I'm using the following code in visual studio 2008:

      std::vector< double >::iterator location;
      location=std::find(vec.begin(),vec.end(),0.);

      and I'm getting the error:

      error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::_Vector_iterator<_Ty,_Alloc>' (or there is no acceptable conversion)

      My header files are as follows (I know all these aren't necessary for this small portion of code, but the rest of my code requires the additional headers):

      #include "stdafx.h"

      #include <algorithm>
      #include <iostream>
      #include <vector>

      //#include <sstream>
      #include <fstream>
      #include <string>
      #include <ostream>

      Does anyone know how to fix this? Is it possibly a visual studio project setting :confused: Thanks!

      N Offline
      N Offline
      Nemanja Trifunovic
      wrote on last edited by
      #2

      A fresh VC++ 2008 console project compiles the following code just fine:

      #include <vector>
      #include <algorithm>

      int main()
      {
      std::vector<double> vec;
      std::vector< double >::iterator location;
      location=std::find(vec.begin(),vec.end(),0.);
      }

      Also, be careful when comparing floating-point numbers[^]

      utf8-cpp

      B 1 Reply Last reply
      0
      • N Nemanja Trifunovic

        A fresh VC++ 2008 console project compiles the following code just fine:

        #include <vector>
        #include <algorithm>

        int main()
        {
        std::vector<double> vec;
        std::vector< double >::iterator location;
        location=std::find(vec.begin(),vec.end(),0.);
        }

        Also, be careful when comparing floating-point numbers[^]

        utf8-cpp

        B Offline
        B Offline
        b rad311
        wrote on last edited by
        #3

        Thanks!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups