#include <Turboc.h>

 

class Time

{

private:

     int hour,min,sec;

 

public:

     Time() { }

     Time(int h, int m, int s) { hour=h; min=m; sec=s; }

     void OutTime() {

          printf("%d:%d:%d\n",hour,min,sec);

     }

     int &operator [](int what) {

          switch (what) {

          case 0:

              return hour;

          case 1:

              return min;

          default:

          case 2:

              return sec;

          }

     }

     const int &operator [](int what) const {

          switch (what) {

          case 0:

              return hour;

          case 1:

              return min;

          default:

          case 2:

               return sec;

          }

     }

};

 

void main()

{

     Time A(1,1,1);

     const Time B(7,7,7);

 

     A[0]=12;

     printf("현재 %d시입니다.\n",A[0]);

     //B[0]=8;

     printf("현재 %d시입니다.\n",B[0]);

}






여기에서 int &operator [](int what) 이게 먼지 잘모르겟구


 Time(int h, int m, int s) { hour=h; min=m; sec=s; } 이부분도 잘모르겟어요       


구조체 구조가 이렇개 될수잇나요?