목록C++ (20)
Dev fox
#include using namespace std;#include int list[100][100];int inputdata;void printList(int inputdata){ for (int i = 0; i = inputdata) return false; if (y = inputdata) return false; if (list[x][y] != 0) return false; return true;}void buildList(int inputdata){ int x = 0, y = 0; int total = 1; int dir = RIGHT; int dx[] = { 0, 1, 0, -1 }; int dy[] = { 1, 0, -1, 0 }; while (true) { list[x][y] = t..
OOP프로젝트의 마지막 11에서는 예외처리 적용예정 허용되는 숫자보다 프로그램사용자로부터 더 작거나 큰 값을 입력받았을 경우 try catch문으로 예외처리 그 과정에서 AccountException.h 파일을 추가하고 숫자가 입력되거나 계산되는 부분에서 if문으로 먼저 확인하고 정상적이지 않은 값일 경우 throw로 Exception 클래스로 전달함 추가한 파일 1. AccountException.h #ifndef __ACCOUNT_EXCEPTION_H__ #define __ACCOUNT_EXCEPTION_H__ class MinusException { private: int exval; public: MinusException(int val) : exval(val) {} void ShowExcepti..
10에서는 저번에 만들었던 AccountArray를 대체할 클레스 템플릿을 정의해 다양한 데이터를 저장할 수 있도록 일반화하는 것이 목표다. BoundCheckArray 이름의 헤더파일을 만들고 같은 이름으로 클래스 템플릿 정의 1. BoundCheckArray.h #ifndef __BOUNDCHECKARRAY_H__ #define __BOUNDCHECKARRAY_H__ template class BoundCheckArray { private: T* arr; int arrlen; //배열에 대한 복사 및 대입방지 BoundCheckArray(const BoundCheckArray& arr) {} BoundCheckArray& operator=(const BoundCheckArray& arr) {} pub..
09에서는 직접 정의한 string 클래스를 가지고 기존 프로젝트의 char를 string으로 대체함 String클래스를 정의한 String.cpp, String.h 파일 추가 기존에 Account내에 존재하는 복사 생성자, 대입 연산자, 소멸자는 String 클래스가 추가됨에 따라서 사용하지않게되므로 주석 처리해줌 1. String.h #ifndef __STRING_H__ #define __STRING_H__ #include "BankingCommonDec1.h" class String { private: int len; char* string; public: String(); String(const char* str); String(const String& str); String& operator=(..