본문 바로가기

C++ 언어

(39)
은행계좌 관리 프로그램 버전5 프로그램 추가 조건 조건1) AccountHandler라는 이름의 컨트롤 클래스를 정의하고, 앞서 정의한 전역함수들을 이 클래스의 멤버함수에 포함시킨다. 조건2) Account 객체의 저장을 위해 선언한 배열과 변수도 이 클래스의 멤버에 포함시킨다. 조건3) AccountHandler 클래스 기반으로 프로그램이 실행되도록 main 함수를 변경한다. 조건4) 버전4의 코드를 가져와서 변경한다. 실행결과 코드 #include #include using namespace std; const int NAME_LEN = 20; enum { MAKE = 1, DEPOSIT, WITHDRAW, INQUIRE, EXIT }; /* * 클래스 이름: Account * 클래스 유형: Entity 클래스 */ class A..
C++언어 연습문제34 [문제] 아래의 main 함수를 참고하여 클래스를 수정하라. 조건1) 문제33의 클래스를 기본으로 할 것 조건2) 상속을 사용하지 말 것 int main(void) { Police pman1(5, 3); pman1.Shot(); pman1.PutHandcuff(); Police pman2(0, 3); pman2.Shot(); pman2.PutHandcuff(); return 0; } [실행결과] BBANG! SNAP! Hut BBANG! SNAP! [코드] #include using namespace std; class Gun { private: int bullet; public: Gun(int bnum) :bullet(bnum) {} void Shot() { cout
C++언어 연습문제33 [문제] 아래 main 함수를 참고하여 Gun, Police 클래스를 설계하라. 조건) 상속을 이용할 것 int main(void) { Police pman(5, 3); pman.Shot(); pman.PutHandcuff(); return 0; } [실행결과] BBANG! SNAP! [코드] #include using namespace std; class Gun { private: int bullet; public: Gun(int bnum) :bullet(bnum) {} void Shot() { cout
C++언어 연습문제32 [문제] 아래의 실행결과와 main함수를 참고하여 Person class와 UnivStudent class를 정의하라. 조건1) UnivStudent 는 유도 클래스로, Person은 기초 클래스로 정의하라. 조건2) 동적 할당을 사용하라. int main(void) { UnivStudent ust1("Kim", "Mathematics"); ust1.WhoAreYou(); UnivStudent ust2("Yoon", "Physics"); ust2.WhoAreYou(); return 0; } [실행결과] My name is Kim My major is Mathematics My name is Hong My major is Physics [코드] #include using namespace std; clas..
C++언어 연습문제31 [문제] 아래의 실행결과와 main함수를 참고하여 Person class와 UnivStudent class를 정의하라. 조건) UnivStudent 는 유도 클래스로, Person은 기초 클래스로 정의하라. int main(void) { UnivStudent ust1("Lee", 22, "Computer eng."); ust1.WhoAreYou(); UnivStudent ust2("Yoon", 21, "Electronic eng."); ust2.WhoAreYou(); return 0; } [실행결과] My name is Lee I'm 22 years old My major is Computer eng. My name is Yoon I'm 21 years old My major is Electronic e..
C++언어 연습문제30 [문제] 아래의 실행결과가 나오도록 클래스와 main함수를 구성하라. 조건1) 정규직 직원에 대한 PermanentWorker 클래스를 정의할 것 조건2) 기능의 처리를 실제로 담당하는 EmployeeHandler 컨트롤 클래스를 정의하고 아래의 기능의 함수를 추가할 것 - 새로운 직원정보의 등록: AddEmployee - 모든 직원의 이번 달 급여정보 출력: ShowAllSalaryInfo - 이번 달 급여의 총액 출력: ShowTotalSalary [실행결과] name: KIM salary: 1000 name: LEE salay: 1500 name: JUN salay: 2000 salary sum: 4500 [코드] #include using namespace std; class PermanentWo..
은행계좌 관리 프로그램 버전4 프로그램 추가 조건 조건1) class에 const 선언을 추가할 것 조건2) 코드는 은행계좌 관리 프로그램 버전3를 가져와 변경할 것 실행결과 코드 #include #include using namespace std; const int NAME_LEN = 20; void ShowMenu(void);//메뉴출력 void MakeAccount(void);//계좌개설을 위한 함수 void DepositMoney(void);//입 금 void WithdrawMoney(void);//출 금 void ShowAllAccInfo(void);//잔액조회 enum { MAKE = 1, DEPOSIT, WITHDRAW, INQUIRE, EXIT }; class Account { private: int accID; int..
C++ 언어 연습문제29 [문제] 아래의 코드에서 전역변수로 선언된 변수를 static변수로 변경하여라. #include using namespace std; int simObjCnt = 0; int cmxObjCnt = 0; class SoSimple { public: SoSimple() { simObjCnt++; cout