【发布时间】:2014-01-08 20:26:51
【问题描述】:
我收到了这个恼人的错误 C2678: binary '>' : no operator found 接受左操作数。 我想使用 find_if 来查找除数和迭代器的返回值,以添加到向量中。 我会很感激任何想法。
头文件
#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 文件
#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);
}
}
}
}
}
【问题讨论】:
-
请从不在标题中放置 using 指令或声明。我不希望在包含标题时引入额外的垃圾。
-
@chris 我会记住的。谢谢!
标签: c++ visual-studio