Iterator gives error
-
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!
-
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!
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[^]
-
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[^]