vendredi 17 avril 2015

Compile error of C++ program even though string is included

I had some help on my code which finds differences between XML files, this is my code:



#include <string>
#include <cstring>
#include <map>
#include <iostream>

#include "pugi/pugixml.hpp"

int main() {
pugi::xml_document doca, docb;
std::map<string, pugi::xml_node> mapa, mapb;

if (!doca.load_file("a.xml") || !docb.load_file("b.xml"))
return 1;

for (auto& node: doca.child("site_entries").children("entry")) {
const char* id = node.child_value("id");
mapa[new std::string(id, strlen(id))] = node;
}

for (auto& node: docb.child("site_entries").children("entry"))
const char* idcs = node.child_value("id");
std::string id = new std::string(idcs, strlen(idcs));
if (!mapa.erase(id)) {
mapb[id] = node;
}
}

}


I included string but it still seems to give me this error and I'm not sure why. Could anyone give me an idea what I am doing wrong please?


src/main.cpp:12:14: error: unknown type name 'string'; did you mean 'std::string'? std::map<string, pugi::xml_node> mapa, mapb; ^~~~~~ std::string /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:189:65: note: 'std::string' declared here typedef basic_string<char, char_traits<char>, allocator<char> > string;


Aucun commentaire:

Enregistrer un commentaire