I'm trying to figure out the best way to match an object to a an object in a list:
Code:
void clientInfo::addToList(clientInfo client){
theList.push_back(client);
}
void clientInfo::delFromList(clientInfo client){
// Create constant iterator for list.
list<int>::const_iterator iter;
// Iterate through list and output each element.
for (iter = theList.begin(); iter != theList.end(); iter++){
if ((*iter) == client)){
MessageBox(NULL, "Match", "List", MB_OK);
}
}
}
Gives me
c:\Documents and Settings\Cody Harris\My Documents\Visual Studio Projects\UpdateServer\clientinfo.cpp(19): error C2059: syntax error : ')'
c:\Documents and Settings\Cody Harris\My Documents\Visual Studio Projects\UpdateServer\clientinfo.cpp(7): error C2664: 'std::list<_Ty>:

ush_back' : cannot convert parameter 1 from 'clientInfo *const ' to 'const clientInfo &'
with
[
_Ty=clientInfo
]
c:\Documents and Settings\Cody Harris\My Documents\Visual Studio Projects\UpdateServer\clientinfo.cpp(18): error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'std::list<_Ty>::const_iterator' (or there is no acceptable conversion)
with
[
_Ty=int
]
c:\Documents and Settings\Cody Harris\My Documents\Visual Studio Projects\UpdateServer\clientinfo.cpp(19): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const std::allocator<_Ty>::value_type' (or there is no acceptable conversion)
with
[
_Ty=int
]
c:\Documents and Settings\Cody Harris\My Documents\Visual Studio Projects\UpdateServer\clientinfo.cpp(18): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::list<_Ty>::iterator' (or there is no acceptable conversion)
with
[
_Ty=clientInfo
]
]
The clientinfo class is as follows:
Code:
class clientInfo{
public:
//Constuctors/Destructors
clientInfo(SOCKET sock, LPSOCKADDR lpSockAddrIn, int nAddrLen);
//Public Functions:
int matchSock(SOCKET sock);
int getState();
void setState();
//Static functions
static clientInfo findClient(SOCKET sock);
static void addToList(clientInfo client);
static void delFromList(clientInfo client);
private:
SOCKET clientSock;
LPSOCKADDR lpSockAddr;
static list<clientInfo> theList;
};