I have a class, how can i add one object of this class to map, and find it by id?
Class code:
class Client {
int FileDescriptor, Id, cryptcode;
unsigned char CustomData[256];
void PrepareClient()
{
// init code
}
public:
AnticheatClient (int fd, int id, int crypt_code)
{
FileDescriptor = fd;
Id = id;
cryptcode = crypt_code;
PrepareCrypt();
}
void OwnCryptEncrypt(unsigned char* data, int len)
{
//...
}
void OwnCryptDecrypt(unsigned char* data, int len)
{
//...
}
};
std::map<int, Client> ClientTable;
int main()
{
int id = 1;
Client c(1, id, 1);
// how can i add this client to map and how can i find it by id?
}
I tried so many example codes but not with custom class so they didn't work. Thanks!