굳이 C++ 에서 struct 쓸이유있나여?




// 화투 한장을 표현하는 클래스

struct SCard

{

     char Name[4];

     SCard() { Name[0]=0; }

     SCard(const char *pName) {

          strcpy(Name,pName);

     }

     int GetNumber() const {

          if (isdigit(Name[0])) return Name[0]-'0';

          if (Name[0]=='J') return 10;

          if (Name[0]=='D') return 11;

          return 12;

     };

     int GetKind() const {

          if (strcmp(Name+1,"광")==0) return 0;

          else if (strcmp(Name+1,"십")==0) return 1;

          else if (strcmp(Name+1,"오")==0) return 2;

          else return 3;

     }

     friend ostream &operator <<(ostream &c, const SCard &C) {

          return c << C.Name;

     }

     bool operator ==(const SCard &Other) const {

          return (strcmp(Name,Other.Name) == 0);

     }

     bool operator <(const SCard &Other) const {

          if (GetNumber() < Other.GetNumber()) return true;

          if (GetNumber() > Other.GetNumber()) return false;

          if (GetKind() < Other.GetKind()) return true;

          return false;

     }

};