I don't really have the hang of declaring identifiers. This is the code I have:
#include "pugi/pugixml.hpp"
#include <iostream>
#include <string>
#include <map>
int main() {
pugi::xml_document doca, docb;
std::map<std::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[id] = node;
}
for (auto& node: docb.child("site_entries").children("entry"))
const char* idcs = node.child_value("id");
if (!mapa.erase(id)) {
mapb[id] = node;
}
}
for (auto& ea: mapa) {
std::cout << "Removed:" << std::endl;
ea.second.print(std::cout);
}
for (auto& eb: mapb) {
std::cout << "Added:" << std::endl;
eb.second.print(std::cout);
}
I get quite a few errors when trying to compile but one that comes up a few times is the error error: use of undeclared identifier
for example:
- src/main.cpp:21:25: error: use of undeclared identifier 'id' if (!mapa.erase(id)) { ^
- src/main.cpp:22:18: error: use of undeclared identifier 'id' mapb[id] = node; ^
- src/main.cpp:22:24: error: use of undeclared identifier 'node' mapb[id] = node;
After reading this topic it seems to be talking about not including iostream without string, but I have done this.
https://stackoverflow.com/a/22197031/1738522
I'm very new to C++ so any help would be appreciated.