C++

'객체 지향 프로그래밍 | Objecet Oriented Programming (OOP)' 이란 무엇일까요? 이를 더 잘 이해하기 위해서, 우리가 기존에 주로 사용하던 Procedural Programming, 절차적 프로그래밍을 우선 이해 해 봅시다. 절차적 프로그래밍 | Procedural Programming (PP) 절차적 프로그래밍의 핵심 포인트는 '함수' 입니다. PP 프로그램은 기본적으로 함수의 집합 입니다. 또한, 우리는 데이터를 개별적으로 선언합니다. 그리고 필요시에 해당 데이터들을 함수에 인자로써 전달하여 활용합니다. 필요한 용도에 맞춰 과정을 분석하고, 나누어서 함수를 선언하고 사용하는 방법이기에 이해하기 매우 직관적입니다. 하지만 절차적 프로그래밍에는 분명한 한계들이 존재합니다. 대..
·C++/기타
2023.12.23 기준 M2 MAC 디버깅 관련 파일들 기록 codelldb extension 사용 중 //c_cpp_properties.json { "configurations": [ { "name": "Mac", "includePath": [ "${workspaceFolder}/**" ], "defines": [], "macFrameworkPath": [ "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" ], "compilerPath": "/usr/bin/clang", "cStandard": "c17", "cppStandard": ..
string mystr = "Hello Guys!"; const char *c_mystr = mystr.c_str(); cout
C++에서 함수는 포인터들도 리턴할 수 있습니다. 그러한 함수들은 type *funcion(); 의 형태로 선언됩니다. 한가지 중요한 점은 '절대로 함수 내의 로컬 변수를 리턴하지 않는다.' 입니다. 간단한 예시 코드를 살펴보겠습니다. int *largest_int(int *int_ptr1, int *int_ptr2){ if (*int_ptr1 > *int_ptr2) return int_ptr1; else return int_ptr2; } 두개의 정수 포인터를 비교하여 더 큰 값의 정수의 포인터를 반환합니다. 이 함수를 사용하는 메인 함수의 예시는 다음과 같을 수 있습니다. int main() { int a {30}; int b {40}; int *largest_ptr{nullptr}; largest_p..
Ricky U. Lee
'C++' 카테고리의 글 목록 (6 Page)