mardi 31 mars 2015

get value from std::map in c++ which has custom type

I have initialized a map as:



typedef void* ProxyClientHandler;
std::map<string,ProxyClientHandler> connectedClient;


And I am inserting values into this map as



ProxyClientHandler client;
string device;
connectedClient.insert ( std::pair<string,ProxyClientHandler>(device,client) );


no error returns upto this.


But when i am going to access the value of given relevant key as



string deviceId;
ProxyClientHandler client = connectedClient.find(deviceId);


it gives me an error:



error: cannot convert ‘std::map, void*>::iterator {aka std::_Rb_tree_iterator, void*> >}’ to ‘ProxyClientHandler {aka void*}’ for argument ‘1’ to ‘int DHProxyClientDelPort(ProxyClientHandler, int)’



how can i fix this issue???


Aucun commentaire:

Enregistrer un commentaire