Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <ostream>
- #include <tuple>
- class playervars {
- private:
- typedef std::tuple<char,int> key_t;
- typedef std::map<key_t, int> m_i;
- m_i m;
- public:
- void SetInt(int playerid, char letter, int valor) {
- m[std::make_tuple(letter,playerid)] = valor;
- }
- int GetInt(int playerid, char letter) {
- auto itr = m.find(std::make_tuple(letter,playerid));
- if (m.end() != itr)
- {
- return itr->second;
- }
- return -1;
- }
- bool Delete(int playerid, char letter) {
- auto itr = m.find(std::make_tuple(letter,playerid));
- if (m.end() != itr)
- {
- m.erase(std::make_tuple(letter,playerid));
- return true;
- }
- return false;
- }
- };
- playervars PVar;
- int main() {
- PVar.SetInt(5,'l',10);
- std::cout << PVar.GetInt(5,'l') << std::endl;
- system("pause");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement