I wrote a function that checks if a certain index is present in a map.
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <map>
#include <string>
#include <vector>
#include <iterator>
bool search(typename std::map<std::string, std::string> m, std::string s) {
typename std::map<std::string, std::string>::iterator mi;
mi= m.find(s);
if(mi != m.end())
return true;
else
return false;
}
When I tried to compile the code using the g++ compiler on Ubuntu, the error message I got for the line :
‘mi’ was not declared in this scope.
Earlier I had not included the keyword typename, I changed that on reading the answer to a similar question here however I still had the same problem. The code involves socket programming and the map is used for a key value store implemented at the server end, hence the relevant header files.
Aucun commentaire:
Enregistrer un commentaire