Search
castle

전체 구성요소

프로그램 언어를 효율적으로 학습하는 방법은 전체적으로 언어가 갖고 있는 구성과 특징을 알고 많은 코드를 만들고 실행해 보는 것이다.

프로그램은 순차(sequence), 분기(selection), 반복(iteration)의 집합체이다. 그 집합체를 함수(function)라고 하며 자료형(data types)으로 변수(variables)를 만들고 자료를 저장한다. 프로그래밍 언어는 발전하였고 개발 도구는 환상적이다. 하지만 컴퓨터 프로그래밍의 주요 요소와 구성은 변한 것이 없다.

컴퓨터 프로그래밍 언어와 사람의 언어 관계에서 변수(variable)는 명사(noun)이고 함수(function)는 동사(verb)이다.

사용자 정의 자료형은 두 가지 목적을 갖고 있다. 하나는 값처럼 사용하는 자료형이고 다른 하나는 처리를 위한 것이다.

C++ 객체지향 언어가 아니다. 객체지향 기능을 지원하는 프로그래밍 언어이다. 절차지향과 객체지향을 적절하게 활용함으로써 운영 시스템에 최적화된 코드를 만들 수 있다.

C++의 전체적인 구성은 아래 그림과 같다. 아래 그림을 저장한 후 원본 크기로 확인해 보자.

C++_Story_by_seadog.png

Preprocessor

  • #define, #undef
  • #ifdef, #ifndef, #else, #endif
  • #include, #pragma

Namespaces

  • using
  • namespace new_name = current_name
  • std, alias, identifier

Types

기본 타입

  • Integers: char, short, int, long
  • Floating: float, double, unsigned
  • Boolean: bool

복합 타입

  • Arrays: []
  • Pointers: new, delete, nullptr
  • Function pointers
  • References: &, &&
  • Smart pointers: shared_ptr, weak_ptr, unique_ptr, auto_ptr

Classes

  • Access control: public, protected, private, default
  • Constructors: explicit, overloading, copy constructor
  • Assign operator
  • Destructor: virtual
  • Virtual functions, Pure virtual functions
  • Overloading:
    • Function overloading
    • Operator overloading
  • Inheritance: base, derived
  • Friend, Function objects, Variables
  • Structs: almost same as classes (members are public by default)
  • Enumeration: enum

Casting

  • User types: single, multiples
  • Inheritance → Function Classes
  • Casting types:
    • dynamic_cast
    • static_cast
    • const_cast
    • reinterpret_cast
    • safe_cast

Templates

  • <>, typename
  • Function templates
  • Variadic function templates
  • Class templates
  • Template specialization
  • Non-type parameters
  • Metaprogramming

Polymorphism

  • Virtual functions, Pure virtual functions
  • Overriding
  • 다형성 구현 → 클래스 상속 기반

Exceptions

  • Logic errors, Runtime errors
  • Standard exceptions, User-defined exceptions
  • try-catch, noexcept

Libraries

  • C++ Standard Libraries
  • System Libraries
  • User Libraries

Functions

  • Arguments, Parameters, Default arguments
  • Return types
  • Overloading, Inline, Inline assembly
  • constexpr
  • Mixing C: extern "C", #ifdef __cplusplus
  • Calling conventions:
    • __cdecl
    • __stdcall
    • __fastcall

Statements

  • 조건문: if, else, else if, switch, case, default
  • 반복문: while, do-while, for
  • 흐름 제어: continue, break, goto
  • 식별자: identifier

Expressions

  • Assignments
  • Scope resolution (::)
  • Arithmetic, Bitwise/Logical operators
  • Increment/Decrement
  • Type conversion:
    • Implicit
    • Explicit
  • Pre/Post ops
  • Member selectors
  • Comparison operators
  • Lambdas
left
right

C

Contents