변수와 기본 타입
C++의 기본 타입 크기와 플랫폼 의존성, `auto` 타입 추론, `const`와 `constexpr`의 차이, 중괄호 초기화가 좁히기 변환을 막는 이유를 정리합니다.
#include <cstdint>
#include <string>
int main() {
int count = 42;
double ratio = 0.75;
bool ready = true;
std::int32_t id = 1001; // 외부 형식이 32 bit를 요구할 때
std::string name{"RefDock"};
const double pi = 3.14159; // 초기화 뒤 대입하지 않는다.
constexpr int max_n = 100; // 상수 평가가 필요한 값
return ready && count < max_n && ratio < pi && id != 0 && !name.empty() ? 0 : 1;
}