X
XX
Please help, and thanks.....
How to compare iterator with class [s==skip_share].
Return iterator as a class record [return s;].
error C2678: binary '==' : no operator found which takes a left-hand operand
of type 'std::list<_Ty>::_Iterator<_Secure_validation>' (or there is no
acceptable conversion)
error C2440: 'return' : cannot convert from
'std::list<_Ty>::_Iterator<_Secure_validation>' to 'cShare *'
#include <list>
using namespace std;
class cShare {
private:
int connection_id;
public:
cShare(int _connection_id);
int Get_connection_id(void) const { return connection_id; };
};
cShare::cShare(int _connection_id)
{
connection_id = _connection_id;
}
class cShares
{
private:
list<cShare> cshares;
public:
cShares();
virtual ~cShares();
cShare *cShares::SearchCon(int connection_id, cShare *skip_share);
};
cShares::cShares()
{
}
cShares::~cShares()
{
}
cShare *cShares::SearchCon(int connection_id, cShare *skip_share)
{
list<cShare>::const_iterator s;
for (s = cshares.begin(); s != cshares.end(); ++s) {
if(s==skip_share) continue;
if(s->Get_connection_id()==connection_id) return s;
}
return NULL;
}
How to compare iterator with class [s==skip_share].
Return iterator as a class record [return s;].
error C2678: binary '==' : no operator found which takes a left-hand operand
of type 'std::list<_Ty>::_Iterator<_Secure_validation>' (or there is no
acceptable conversion)
error C2440: 'return' : cannot convert from
'std::list<_Ty>::_Iterator<_Secure_validation>' to 'cShare *'
#include <list>
using namespace std;
class cShare {
private:
int connection_id;
public:
cShare(int _connection_id);
int Get_connection_id(void) const { return connection_id; };
};
cShare::cShare(int _connection_id)
{
connection_id = _connection_id;
}
class cShares
{
private:
list<cShare> cshares;
public:
cShares();
virtual ~cShares();
cShare *cShares::SearchCon(int connection_id, cShare *skip_share);
};
cShares::cShares()
{
}
cShares::~cShares()
{
}
cShare *cShares::SearchCon(int connection_id, cShare *skip_share)
{
list<cShare>::const_iterator s;
for (s = cshares.begin(); s != cshares.end(); ++s) {
if(s==skip_share) continue;
if(s->Get_connection_id()==connection_id) return s;
}
return NULL;
}