Reputation: 49
I'm getting this annoying error C2678: binary '>' : no operator found which takes a left-hand operand. I want to use find_if to find a divisor number and the returned value by the iterator to be added in a vector. I would appreciate any ideas.
Header file
#ifndef SMTH_H
#define SMTH_H
#include <vector>
#include <iostream>
using namespace std;
using std::vector;
namespace Calculator{
namespace Cal{
typedef unsigned int Uint;
typedef vector<Uint> TVint;
typedef vector<Uint>::const_iterator TIterator;
/..../
class TestPrim : public Sir
{
protected:
Uint _val;
double _stopVal;
public:
Uint testPrim;
TestPrim(Uint val);
TestPrim& operator ++();
bool operator () (Uint divizor);
operator Uint ();
friend bool operator > (Uint val, const TestPrim &src);
};
}
}
#endif
Cpp file
#include <iomanip>
#include "smth.h"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
namespace Calculator{
namespace Cal{
/..../
class TestPrim;
void Prime::CalculeazaValori(int index)
{
if(index > MAX_PRIME)
{
throw errorCheck();
}
if(index == 0)
{
_elemente.push_back(2);
_elemente.push_back(3);
}
for (TestPrim testPrim = (_elemente.back() + 2); _elemente.size() < _count; ++testPrim)
{
TIterator it = find_if (_elemente.begin(), _elemente.end(), testPrim );
if (it > testPrim) //error on this line
{
_elemente.push_back(testPrim);
}
}
}
}
}
Upvotes: 0
Views: 1537
Reputation: 227370
This is what your operator looks like:
friend bool operator > (Uint val, const TestPrim &src);
and this is how you are using it:
it > testPrim
it
is a TIterator
, not a Uint
. Presumably you meant
*it > testPrim
Upvotes: 1