Iterators/Functions.
[Request close, Solved]
I am currently coding a basic server using Qt (Why Qt? Because. Its not important anyway) In one of my functions called when someone connects to my server, there is this part of code :
Code:
for(vector<DBase*>::iterator it = clients.begin(); it != clients.end() ; ++it)
{
if((*it)->getSocket() == socket)
{
(*it)->setName(_switch);
logBox->append("[" + QString((*it)->getName()) + "] Connecté");
break; //On arrete le if pour accélérer;
}
}
DBase is a class I made which stores the name of the client and a pointer to his socket on my server. Everything works fine in this part of the code.
The name is stored using the method setName() and showed using the method getName(). They both work good.
Here are the two functions used in this statement
Code:
char* getName()
{
return nom_client;
}
void setName(char* _name)
{
nom_client = _name;
}
Code:
for(vector<DBase*>::iterator it = clients.begin(); it != clients.end() ; ++it)
{
if((*it)->getSocket() == socket && (*it)->getSocket()!= NULL && socket != NULL)
{
_name = QString((*it)->getName()); // _name != Erreur
break;
}
}
logBox->append("[Déconnexion Client] " + _name);
Does anyone see an error?
