Loading...

함수 템플릿

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include #include template T max(T& a, T& b) { return a > b ? a : b; } int main() { int a = 1, b = 2; std::cout

템플릿 (Template)

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#include #include // T를 템플릿 인자로 받는 템플릿 정의template class Vector { T* data; int capacity; int length; public: Vector(int n = 1): data(new T[n]), capacity(n), length(0){} void push_back(T s) { if (capacity

2020. 8. 25. 22:06

Web server failed to start. Port 8080 was already in use

포트가 이미 실행중일때 발생하는 에러 명령 프롬포트 창에서 netstat -ano 입력 해당하는 포트의 pid 번호를 찾은 뒤 taskkill /pid (pid번호) /f 입력 --> 포트 강제종료

Stack 구현 (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 #include class Stack { int* data; int s_size; int s_top; public: Stack(int n); void push(int n); void pop(); int top(); bo..

Queue 구현 (c++)

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293#include class Queue { int* data; // 데이터를 저장하는 배열 int q_size; // 큐의 사이즈 int front; // 가장 먼저 넣은 요소 표시 int rear; // 가장 나중에 넣은 요소 표시 public: Queue(int n); void push(int x); void pop(); bool is_full(); bool empty(); int size(..

Vector 구현 (c++)

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485#include #include using std::string;class Vector { string* data; // 데이터를 보관하기 위한 문자열 배열 int capacity; // 현재 할당되어 있는 크기 int length; // 실제 사용중인 크기public: Vector(int n = 1); void push_back(string s); string operator[](int i); void insert(st..

2020. 8. 20. 16:33

오버라이딩, 가상함수

오버라이드 class Base { std::string s; public : Base() : s("기반") { std::cout

오버로딩

Soma_class a = b; - a의 복사 생성자가 호출 Some_class a; a = b; - a의 기본 생성자가 호출된 뒤, 다음 문장에서 대입 연산자 함수가 실행