Skip to content

Instantly share code, notes, and snippets.

@daghlny
Created May 21, 2018 11:02
Show Gist options
  • Save daghlny/e09df10731d00aac369833b9e2967a0a to your computer and use it in GitHub Desktop.
Save daghlny/e09df10731d00aac369833b9e2967a0a to your computer and use it in GitHub Desktop.
#include <string>
#include <unordered_map>
#include <string>
#include <iostream>
class Base {
public:
Base() :testMap{ {"a",1}, {"b", 2}, {"c", 3}, {"d", 4} } {
}
virtual ~Base() = default;
void display() {
for (auto &w : testMap) {
std::cout << w.first << ' ';
std::cout << w.second << std::endl;
}
}
protected:
std::unordered_map<std::string, int> testMap;
};
class unBase : public Base {
public:
unBase() {
testMap["a"] = 10;
}
};
int main() {
unBase test;
test.display();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment