Created
May 21, 2018 11:02
-
-
Save daghlny/e09df10731d00aac369833b9e2967a0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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