|
남병철.레조 님이 쓰신 글 :
: 안녕하세요? 레조입니다.
:
: 3가지 정도 수정후에 잘 컴파일 되어 화면이 나오네요.
: 결과는 이미지 첨부했습니다.
:
: void setTime( int h, int m, int s) {
: 이부분에 scope 연산자 없네요.
:
: << ( second < 10 ? "0" : "" ) << second MM ":"
: 이부분의 MM 오타 맞죠? ^^ << 이걸로 빠구시길..
:
: << ( hour < 12 ? "AM" : "PM"); endl;
: 이부분에서 ; 요걸 << 이걸루
:
: 이렇게 3개만 고치면 컴파일 됩니다.
:
: << time.h >>
: class Time {
: public :
: Time();
: void setTime( int , int ,int);
: void printMilitary();
: void printStandard();
: private :
: int hour;
: int minute;
: int second;
: };
:
:
:
: << time.cpp >>
: #include <iostream>
: using std::cout;
: using std::endl;
:
: #include "time.h"
:
: Time::Time() { hour = minute = second = 0 ; }
:
: void Time::setTime( int h, int m, int s) {
: hour = ( ( h >=0 || h < 24 ) ? h : 0 );
: minute = ( ( m >=0 || m < 60) ? m : 0 );
: second = ( ( s >=0 || s < 60) ? s : 0 );
: }
:
: void Time::printMilitary() {
: cout << ( hour < 10 ? "0" : "" ) << hour << ":"
: << ( minute < 10 ? "0" : "" ) << minute << endl;
: }
:
: void Time::printStandard() {
: cout << (hour == 0 || hour == 12 ? 12 : hour) << ":"
: << ( minute < 10 ? "0" : "") << minute << ":"
: << ( second < 10 ? "0" : "" ) << second << ":"
: << ( hour < 12 ? "AM" : "PM") << endl;
: }
:
:
:
: << flg.cpp >>
: #include <iostream>
: using std::cout;
: using std::endl;
:
: #include "time.h"
:
: #include <conio.h>
:
:
: int main() {
: Time t;
:
: cout << "Initial Time\n";
: t.printMilitary();
: t.printStandard();
:
: t.setTime( 13, 24, 23);
:
: cout << "\nAfter time setting\n";
: t.printMilitary();
: t.printStandard();
:
: t.setTime(99,99,99);
: cout << "\nAfter Iilegal time setting\n";
:
: t.printMilitary();
: t.printStandard();
:
: getch();
:
: }
:
|