분류 전체보기 (129) 썸네일형 리스트형 [C++] Template Class (템플릿 클래스) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include #include #pragma once using namespace std; template class MyTemplate { T data; public : MyTemplate(T_data); int Compare(T in); operator T(); }; template MyTemplate ::MyTemplate(T_data) { data = _data; } template int MyTemplate::Compare(T in) { return data - in; } template MyTemplate::operator T() { return data; }.. [C++] 성적 처리 프로그램 동적바인딩 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 #include using namespace std; void input(char *name, int *score, int num); void oper(int *score, float *avg, int num); void output(char *name, int *score, float *avg, int num); in.. [C++] Static (스태틱) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 #include using namespace std; /* static method 1. class를 통틀어서 오직 하나다 2. this pointer가 존재하지 않는다 3. instance field를 사용할 수 없다 4. 클래스명::메소드() 이렇게 사용도 할 수 있고, 객체 메소드() *p 객체를 만든 후에 가능 */ class A { int a; public .. [C++] 스택, 큐 메모리 템플릿 (Stack, Queue Memory Template) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12.. [C++] Reference(레퍼런스) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 #include using namespace std; void change(int &a, int &b); void main() { int a = 10; int b = 20; int &c = a; //reference 변수 선언 : a를 c로도 부르겠다. /*change(a, b); cout [C++] 순수 가상 함수 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #include using namespace std; /* 순수 가상 함수 virtual void disp() = 0; 자식들에게 강제적으로 오버라이딩을 명령한다. 자식 클래스가 오버라이딩을 하지 않을 경우 자식 클래스도 추상 클래스 화 된다 동적 바인딩 시 원활한 서비스를 제공한다. */ class Area { //추상 클래스 public: virtual void disp() = 0; }; class Rect : public Area { public: void disp() { cout [C++] 급여관리 프로그램 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12.. [C++] Overloading(오버로딩) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #include using namespace std; //오버로딩 : 동일한 하수명으로 여러개의 함수를 제고하는 방법 //조건 : 매개변수의 타입이 달라야한다. // 매개변수의 갯수가 달라야한다. // 리턴타입이 상관없다. void disp(int a, int b); void disp(char a, char b); void disp(float a, float b); void main() { int a = 1, b = 2; char c = 'a', d = 'b'; float e = 3.2f, f = 4.7f; disp(a, b); disp(c, d); dis.. 이전 1 ··· 10 11 12 13 14 15 16 17 다음