Advertisement
Guest User

FFFFFFFFFUUUUUUUUUUUUUUUU

a guest
Dec 12th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <map>
  4. #include <cstdlib>
  5. #include <cstdint>
  6. #include <cstring>
  7. #include <limits>
  8. #include <stdexcept>
  9.  
  10. class String {
  11. private:
  12.     char *data;
  13.     size_t len;    
  14. public:
  15.     String() : len(0) {data = new char[1];}
  16.     String(const char *str) {
  17.         len = strlen(str) + 1;
  18.         data = new char [len];
  19.         strcpy(data, str);
  20.     }
  21.  
  22.     friend std::ostream& operator<< (std::ostream& out, const String str) {
  23.         out << str.data;
  24.         return out;
  25.     }
  26.  
  27.     virtual ~String() {
  28.         delete[] data;
  29.     }
  30. };
  31.  
  32. std::map<unsigned long, String> strings;
  33.  
  34. void test()
  35. {
  36.     std::cout << strings[0];
  37. }
  38.  
  39. int main (int argc, const char *argv[])
  40. {
  41.     strings[0] = "test";
  42.     test();
  43.     std::cout << strings[0];
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement