fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include <map>
  4.  
  5. struct SiteInfo
  6. {
  7. int SiteID;
  8. CString MAC;
  9. CString SiteName;
  10.  
  11. SiteInfo(int ID, CString BelongMAC, CString name)
  12. {
  13. SiteID = ID;
  14. MAC = BelongMAC;
  15. SiteName = name;
  16. }
  17.  
  18. bool operator==(const SiteInfo rhs) const
  19. {
  20. if ((SiteID == rhs.SiteID) && (MAC == rhs.MAC))
  21. return true;
  22. else
  23. return false;
  24. }
  25.  
  26. bool operator<(const SiteInfo rhs) const
  27. {
  28. if (SiteID < rhs.SiteID)
  29. return true;
  30. if (MAC < rhs.MAC)
  31. return true;
  32. if (SiteName < rhs.SiteName)
  33. return true;
  34.  
  35. return false;
  36. }
  37. };
  38.  
  39. int main() {
  40. // your code goes here
  41. CString mac = _T("00:00:00:00:00:01");
  42. SiteInfo site1(1, mac, _T("瞇摸鐵克site1"));
  43. SiteInfo site2(2, mac, _T("西哩科site2"));
  44.  
  45. std::map<SiteInfo, CString> RegisterMap;
  46. RegisterMap.insert(std::make_pair(site1, _T("site1 in map")));
  47. RegisterMap.insert(std::make_pair(site2, _T("site2 in map")));
  48.  
  49. std::map<SiteInfo, CString>::iterator iter1 = RegisterMap.find(site1);
  50. std::map<SiteInfo, CString>::iterator iter2 = RegisterMap.find(site2);
  51.  
  52. return 0;
  53. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:8:2: error: ‘CString’ does not name a type
  CString MAC;
  ^
prog.cpp:9:2: error: ‘CString’ does not name a type
  CString SiteName;
  ^
prog.cpp:11:19: error: ‘CString’ has not been declared
  SiteInfo(int ID, CString BelongMAC, CString name)
                   ^
prog.cpp:11:38: error: ‘CString’ has not been declared
  SiteInfo(int ID, CString BelongMAC, CString name)
                                      ^
prog.cpp: In constructor ‘SiteInfo::SiteInfo(int, int, int)’:
prog.cpp:14:3: error: ‘MAC’ was not declared in this scope
   MAC = BelongMAC;
   ^
prog.cpp:15:3: error: ‘SiteName’ was not declared in this scope
   SiteName = name;
   ^
prog.cpp: In member function ‘bool SiteInfo::operator==(SiteInfo) const’:
prog.cpp:20:34: error: ‘MAC’ was not declared in this scope
   if ((SiteID == rhs.SiteID) && (MAC == rhs.MAC))
                                  ^
prog.cpp:20:45: error: ‘const struct SiteInfo’ has no member named ‘MAC’
   if ((SiteID == rhs.SiteID) && (MAC == rhs.MAC))
                                             ^
prog.cpp: In member function ‘bool SiteInfo::operator<(SiteInfo) const’:
prog.cpp:30:7: error: ‘MAC’ was not declared in this scope
   if (MAC < rhs.MAC)
       ^
prog.cpp:30:17: error: ‘const struct SiteInfo’ has no member named ‘MAC’
   if (MAC < rhs.MAC)
                 ^
prog.cpp:32:7: error: ‘SiteName’ was not declared in this scope
   if (SiteName < rhs.SiteName)
       ^
prog.cpp:32:22: error: ‘const struct SiteInfo’ has no member named ‘SiteName’
   if (SiteName < rhs.SiteName)
                      ^
prog.cpp: In function ‘int main()’:
prog.cpp:41:2: error: ‘CString’ was not declared in this scope
  CString mac = _T("00:00:00:00:00:01");
  ^
prog.cpp:41:10: error: expected ‘;’ before ‘mac’
  CString mac = _T("00:00:00:00:00:01");
          ^
prog.cpp:42:20: error: ‘mac’ was not declared in this scope
  SiteInfo site1(1, mac, _T("瞇摸鐵克site1"));
                    ^
prog.cpp:42:47: error: ‘_T’ was not declared in this scope
  SiteInfo site1(1, mac, _T("瞇摸鐵克site1"));
                                               ^
prog.cpp:45:21: error: the value of ‘CString’ is not usable in a constant expression
  std::map<SiteInfo, CString> RegisterMap;
                     ^
prog.cpp:41:2: note: ‘CString’ was not declared ‘constexpr’
  CString mac = _T("00:00:00:00:00:01");
  ^
prog.cpp:45:28: error: type/value mismatch at argument 2 in template parameter list for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
  std::map<SiteInfo, CString> RegisterMap;
                            ^
prog.cpp:45:28: error:   expected a type, got ‘CString’
prog.cpp:45:28: error: template argument 4 is invalid
prog.cpp:45:41: error: invalid type in declaration before ‘;’ token
  std::map<SiteInfo, CString> RegisterMap;
                                         ^
prog.cpp:46:14: error: request for member ‘insert’ in ‘RegisterMap’, which is of non-class type ‘int’
  RegisterMap.insert(std::make_pair(site1, _T("site1 in map")));
              ^
prog.cpp:47:14: error: request for member ‘insert’ in ‘RegisterMap’, which is of non-class type ‘int’
  RegisterMap.insert(std::make_pair(site2, _T("site2 in map")));
              ^
prog.cpp:49:21: error: the value of ‘CString’ is not usable in a constant expression
  std::map<SiteInfo, CString>::iterator iter1 = RegisterMap.find(site1);
                     ^
prog.cpp:41:2: note: ‘CString’ was not declared ‘constexpr’
  CString mac = _T("00:00:00:00:00:01");
  ^
prog.cpp:49:28: error: type/value mismatch at argument 2 in template parameter list for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
  std::map<SiteInfo, CString>::iterator iter1 = RegisterMap.find(site1);
                            ^
prog.cpp:49:28: error:   expected a type, got ‘CString’
prog.cpp:49:28: error: template argument 4 is invalid
prog.cpp:49:40: error: expected initializer before ‘iter1’
  std::map<SiteInfo, CString>::iterator iter1 = RegisterMap.find(site1);
                                        ^
prog.cpp:50:21: error: the value of ‘CString’ is not usable in a constant expression
  std::map<SiteInfo, CString>::iterator iter2 = RegisterMap.find(site2);
                     ^
prog.cpp:41:2: note: ‘CString’ was not declared ‘constexpr’
  CString mac = _T("00:00:00:00:00:01");
  ^
prog.cpp:50:28: error: type/value mismatch at argument 2 in template parameter list for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
  std::map<SiteInfo, CString>::iterator iter2 = RegisterMap.find(site2);
                            ^
prog.cpp:50:28: error:   expected a type, got ‘CString’
prog.cpp:50:28: error: template argument 4 is invalid
prog.cpp:50:40: error: expected initializer before ‘iter2’
  std::map<SiteInfo, CString>::iterator iter2 = RegisterMap.find(site2);
                                        ^
stdout
Standard output is empty