열혈 C++3 열혈 C++ 프로그래밍 OOP 단계별 프로젝트 06단계 Account 클래스를 상속하는 다음 두 클래스를 추가로 정의한다. NormalAccount HighCreditAccount NormalAccount 생성 과정에서 이율정보를 등록할 수 있도록 하고, HighcreditAccount 생성 과정에서 추가 이율정보를 등록한다. Account 클래스를 상속받는 normalAccount 클래스에 이자 정보를 추가하고, normalAccount 클래스를 상속받는 highcreditAccount 클래스에 추가 이율 정보를 추가한다. #include #include const int NAME_LEN=20; class Accounts //데이터 클래스 { private: int ID; char *name; int amount; int credit; public: Acc.. Algorithm/C++ 2023. 9. 9. 열혈 C++ 프로그래밍 OOP 단계별 프로젝트 02단계 #include #include const int NAME_LEN=20; class Accounts { private: int ID=0; char *name; int amount=0; public: Accounts(const int &ID, char *b, const int &amount) : ID(ID), amount(amount) { name=new char[strlen(b)+1]; strcpy(name,b); } bool Accountcheck(int a) { if(a==ID) return true; else return false; } void deposit(int a) { amount+=a; } void withdraw(int a) { amount-=a; } bool Accountzero() {.. Algorithm/C++ 2023. 7. 22. 열혈 C++ 프로그래밍 문제 4-2 [다양한 클래스의 정의] Circle 객체에는 좌표상의 위치 정보(원의 중심좌표)와 반지름의 길의 정보를 저장 및 출력할 수 있어야 한다. 그리고 여러분이 정의한 Circle 클래스를 기반으로 Ring 클래스도 정의하자. 링은 두 개의 원으로 표현 가능하므로(바깥쪽 원과 안쪽 원), 두 개의 Circle 객체를 기반으로 정의가 가능하다. 참고로 안쪽 원과 바깥쪽 원의 중심좌표가 동일하다면 두께가 일정한 링을 표현하는 셈이되며, 중심좌표가 동일하지 않다면 두께가 일정하지 않은 링을 표현하는 셈이 된다. 하나의 클래스를 정의하더라도, 항상 캡슐화를 고민하기 바란다. #include class Point { private: int xpos; int ypos; public: void init(int x, int y) { xpos=x; .. Algorithm/C++ 2023. 6. 8. 이전 1 다음 💲 추천 글