별의 공부 블로그 🧑🏻‍💻

🗒️ Programming/C++ (117)

728x90
  1. 2017.11.08 [header][container] unordered_set (C++11)

    *[header][container] unordered_set (C++11) Unordered set headerHeader that defines the unordered_set and unordered_multiset container classes: Classesunordered_setUnordered Set (class template )unordered_multisetUnordered Multiset (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/unordered_..

  2. 2017.11.08 [header][container] unordered_map (C++11)

    *[header][container] unordered_map (C++11) Unordered map headerHeader that defines the unordered_map and unordered_multimap container classes: Classesunordered_mapUnordered Map (class template )unordered_multimapUnordered Multimap (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/unordered_..

  3. 2017.11.08 [header][container] forward_list (C++11)

    *[header][container] forward_list (C++11) Forward listHeader that defines the forward_list container class: Classesforward_listForward list (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/forward_list/

  4. 2017.11.08 [header][container] list

    *[header][container] list List headerHeader that defines the list container class: ClasseslistList (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/list/

  5. 2017.11.08 [header][container] deque

    *[header][container] deque Deque headerHeader that defines the deque container class: ClassesdequeDouble ended queue (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/deque/

  6. 2017.11.08 [header][container] stack

    *[header][container] stack Stack headerHeader that defines the stack container class: ClassesstackLIFO stack (class template ) 내용 출처 : http://www.cplusplus.com/reference/stack/

  7. 2017.11.08 [header][container] set

    *[header][container] set Set headerHeader that defines the set and multiset container classes: ClassessetSet (class template )multisetMultiple-key set (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/set/

  8. 2017.11.08 [header][container] queue

    *[header][container] queue Queue headerHeader that defines the queue and priority_queue container adaptor classes: ClassesqueueFIFO queue (class template )priority_queuePriority queue (class template ) 내용 출처 : http://www.cplusplus.com/reference/queue/

  9. 2017.11.08 [header][container] map

    *[header][container] map Map headerHeader that defines the map and multimap container classes: ClassesmapMap (class template )multimapMultiple-key map (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/map/

  10. 2017.11.08 [header][container] array (C++11)

    *[header][container] array (C++11) Array headerHeader that defines the fixed-size array container class: ClassesarrayArray class (class template ) FunctionsbeginIterator to beginning (function template )endIterator to end (function template ) 내용 출처 : http://www.cplusplus.com/reference/array/

  11. 2017.11.08 [header][container] vector

    *[header][container] vector std::vectortemplate class vector; // generic template VectorVectors are sequence containers representing arrays that can change in size. Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as e..

  12. 2017.11.08 [STL] binary_search

    *[STL] binary_search - 이진 탐색 기능을 구현하고 있는 함수.- 헤더 파일 : - 템플릿default (1) template bool binary_search (ForwardIterator first, ForwardIterator last, const T& val); default (2) template bool binary_search (ForwardIterator first, ForwardIterator last, const T& val, Compare comp); - 자세한 내용 : http://www.cplusplus.com/reference/algorithm/binary_search/?kw=binary_search [예제 코드] 123456789101112131415161718..

  13. 2017.10.26 [STL] bitset

    *[STL] bitset - 문자를 2진수로 바꿔주는 함수. - 템플릿 template class bitset; - 자세한 내용 : http://www.cplusplus.com/reference/bitset/bitset/?kw=bitset [예제 코드] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include #include using namespace std; int main() { char a = 2; int b = 16; double c = 64; // bitset(variable) => size : 자릿수, variable : 변수 cout

  14. 2017.10.21 [STL] sprintf

    *[STL] sprintf - int 형식의 문자를 char 형식으로 변환하여 한 문자씩 배열에 넣는 함수. (참고 : CLICK) - 템플릿 int sprintf ( char * str, const char * format, ... ); - 관련 문제 : CLICK - 자세한 내용 : http://www.cplusplus.com/reference/cstdio/sprintf/?kw=sprintf [예제 코드] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include #define N 10 using namespace std; int main() { int num, len; char ary[N]; cin >> num; sprintf(ary, "%..

  15. 2017.10.20 [STL] getline

    *[STL] getline() - C++에서 배열에 공백을 포함한 문장을 입력 받기 위해 필요한 함수. (C의 gets() 함수와 동일한 기능을 가지고 있음.) - C++11 이후, gets() 함수가 C++의 표준 라이브러리에서 제외 되었기 때문에, 공백을 포함한 문장을 입력 받기 위해서는 이 함수가 필요함. - 템플릿 (1) istream& getline (istream& is, string& str, char delim); istream& getline (istream&& is, string& str, char delim); (2) istream& getline (istream& is, string& str); istream& getline (istream&& is, string& str); - 자..

  16. 2017.09.23 [STL] ceil, floor, round

    *[STL] ceil, floor, round - 헤더 파일 (header) C : C++ : - ceil() : 올림 함수 (C90, C99, C++98, C++11) - floor() : 내림 함수 (C90, C99, C++98, C++11) - round() : 반올림 함수(C99, C++11). floor(x + 0.5)로 구현할 수 있음. - 자세한 내용 ceil : http://www.cplusplus.com/reference/cmath/ceil/ floor : http://www.cplusplus.com/reference/cmath/floor/?kw=floor round : http://www.cplusplus.com/reference/cmath/round/?kw=round [예제 코드] 1..

  17. 2017.09.22 [STL] sort

    *[STL] sort - 데이터의 크기에 따라 오름차순 또는 내림차순으로 데이터를 정렬해주는 함수. - C++ 표준라이브러리 헤더에 포함되어 있음. - 헤더 : 내림차순 정렬을 위한 greater을 포함하고 있는 헤더. - sort 함수는 정수뿐만 아니라 크기 비교가 가능한 모든 변수들을 정렬 할 수 있음.- 시간 복잡도 : - 템플릿 default (1) template void sort (RandomAccessIterator first, RandomAccessIterator last); custom (2) template void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp); - 자세한 내용 : http://ww..

  18. 2017.09.02 C++ Character Literals

    C++ Character Literals Value Escape sequence newline \n horizontal tab \t vertical tab \v backspace \b carriage return \r form feed \f alert \a backslash \\ question mark ? or \? single quote \' double quote \" the null character \0 octal \ooo hexadecimal \xhhh Unicode (UTF-8) \uxxxx Unicode (UTF-16) \Uxxxxxxxx Resource from : https://msdn.microsoft.com/en-us/library/6aw8xdf2.aspx

  19. 2017.05.30 인수와 레퍼런스

    * 인수와 레퍼런스 - 포인터를 함수의 인수로 사용하면 호출자의 변수를 변경할 수 있음. - 하지만 포인터는 메모리 주소를 직접 다루기 때문에 어려움. - 레퍼런스(reference) : 변수등으로 초기화한 식별자. 형명 앞에 &를 붙여서 선언함. 형명& 레퍼런스명 = 변수; // 레퍼런스명에는 식별자를 사용함. int a; int& rA = a; // 레퍼런스 rA를 변수 a로 초기화함. -> 이 코드에서 'rA'가 레퍼런스. rA를 변수 a로 초기화한 것. - 예) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #include using namespace std; int main() { int a = 5; int& rA = a; // 레퍼런스 rA를 변수 ..

  20. 2017.05.29 함수 템플릿 (Function Template)

    * 함수 템플릿 (Function Template) - 함수 템플릿(Fundtion Template) : 다루는 형만 다른 함수를 틀을 통해 찍어내듯 만들어낼 때 필요한 틀. - 순서 1. 함수 템플릿을선언 및 정의 2. 함수 호출 (함수가 자동으로 만들어짐.) (1) 함수 템플릿 정의 template // 상황에 맞추어 변경시킬 형(type)의 이름을 지정함. 함수의 선언 혹은 정의 - 부분에는 템플릿 인수라는 것을 집어 넣음. - 템플릿 인수에는 T와 같은 임시 형(type) 이름을 넣음. - 함수 템플릿의 가인수형명은 템플릿 인수임. - 가인수의 구체적인 형(type) 이름 대신 T와 같은 임시 형(type) 이름을 사용함. - 함수 템플릿은 함수의 '틀'이 됨. 1 2 3 4 5 6 7 8 // ..

  21. 2017.05.25 함수 오버로드 (Function Overloading)

    * 함수 오버로드 (Function Overloading) - 인수의 형과 개수가 다르면 같은 이름을 가진 함수를 여러 개 정의할 수 있음. - 예) int max(int x, int y) double max(double x, double y) - 이처럼 인수의 개수 및 형이 다르면서 이름만 같은 함수를 여러 개 정의하는 행위를 일컬어 함수의 오버로드(중복정의 : function overloading)이라고 부름. - 비슷한 함수 여러 개를 같은 이름으로 중복 정의(오버로드)해 두면, 그 이름과 일치하는 함수 중 인수의 형(type)과 개수가 일치하는 함수가 자동적으로 호출됨. - 오버르드 기능을 활용하면 가독성이 높은 코드를 작성할 수 있음. - 오버르드 사용시 주의점 -> 오버로드할 함수는 그 인수의..

  22. 2017.05.25 기본 인수 (Default Argument)

    * 기본 인수 (Default Argument) - 함수 프로토타입 선언 시 기본 인수(default argumet)를 지정하는 것이 일반적임. - 기본 인수를 지정해 두면, 함수 호출시 실인수를 생략할 수 있다는 장점이 있음. - 실인수를 생략하면 미리 지정해둔 기본값이 함수에 넘겨짐. - 기본 인수를 지정한 함수 프로토타입 선언 리턴 값의 형(type) 함수명(형(type) 가인수명 = 기본값, ...); - 기본 인수는 함수 선언 혹은 함수 프로토타입 선언시 한 번만 지정함. - 즉, 함수 프로토타입 선언에서 기본 인수를 지정했다면, 함수 본체를 정의할 때에는 기본 인수를 선언할 수 없음. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2..

  23. 2017.05.25 인라인 함수 (Inline Function)

    * 인라인 함수 (inline function) - 정의 inline 리턴 값의 형 함수 이름(인수리스트) { ... } - 함수 선언부 앞에 inline이 붙여진 함수. - 인라인 함수의 몸체는 컴파일러에 의해 호출 부분에 직접 기록되므로 전체적인 속도 향상을 꾀할 수 있음. - 그러나 너무 긴 코드는 컴파일러가 인라인 함수로 인정하지 않기도 함. - 컴파일러는 간단한 처리만 인라인 함수로 인정하고, 호출 부분에 함수 전체를 기록해 줌.

  24. 2017.05.25 const

    * const - const 키워드 const 형명 식별자 = 식(expression); - const를 사용하여 변수를 초기화하면, 이보다 뒤에 등장한 코드에서는 const가 지정된 해당 변수에 값을 대입할 수 없게 됨. - const로 지정한 변수는 그 값을 변경할 수 없기 때문에, 상수(constant)라고 부르기도 함. - 상수를 사용할 경우, 프로그램 변경이 매우 간편해진다는 장점이 있음. - const 키워드 사용시 주의해야 할 점 1) const 키워드를 지정한 상수는 나중에 그 값을 바꿀 수 없음. (바꾸려고 할 경우 컴파일 오류 발생) 2) const가 지정된 변수는 반드시 초기화 작업이 필요함. (초기화하지 않은 상수에 값을 대입하려 할 경우 컴파일 오류 발생) 1 2 3 4 5 6 7..

  25. 2017.05.25 키보드 입력

    * 키보드 입력 - 키보드에서 입력을 받을 때에는 cin >> 라는 단어를 사용함. - 공백과 같은 입력은 무시됨. - >> 기호에는 키보드 입력을 지정한 변수로 보내는 기능이 있음. 1 2 3 4 5 6 7 8 9 10 11 12 #include using namespace std; int main() { int num = 0; cout num; cout > num2; cout

  26. 2017.05.25 숫자 리터럴 (Number Literal)

    * 숫자 리터럴 - 숫자 리터럴은 다음과 같은 종류가 있음. 1) 정수 리터럴 (Integerl Literal) ex) 3, 4, 100 2) 부동 소수점 리터럴 (Floating-point Literal) ex) 1.4, 3.53 - 숫자 리터럴은 ' '나 " "로 감싸지 않음. - 8진수 및 16진수 표기법 1) 8진수 : 숫자 앞에 0를 붙임. 2) 16진수 : 숫자 앞에 0x를 붙임. 1 2 3 4 5 6 7 8 9 10 11 #include using namespace std; int main() { cout

  27. 2017.05.25 이스케이프 시퀀스 (Escape Sequence)

    이스케이프 시퀀스 의미하는 문자 \a 경고음 \b 백스페이스 \f 페이지 나누기 \n 줄바꿈 \r 복귀 \t 수평 탭 \v 수직 탭 \\ \ \' ' \" " \? ? \ooo 8진수 ooo 문자 코드로 표기할 수 있는 문자 (0는 0~7까지의 숫자) \xhh 16진수 hh 문자 코드로 표기할 수 있는 문자(h는 0~9까지의 숫자와 A~F까지의 영문자)

728x90


📖 Contents 📖