cast_operator

cast_operator (캐스트 연산자)

C++의 형 변환 연산자들(static_cast, dynamic_cast, const_cast, reinterpret_cast)을 소개해요.

출처: cppreference

본문

C++에는 네 가지 명시적 캐스트가 있어요.

static_cast<int>(d);        // 컴파일 시간 변환
const_cast<...>(expr);      // const 제거
dynamic_cast<T*>(p);        // 다형적 하향 변환
reinterpret_cast<T*>(p);    // 비트 재해석

각 캐스트는 용도와 안전성이 달라요.

더 알아보기 (Learn more)

cppreference