[C++11] auto
`auto` 키워드는 C++11부터 도입된 기능으로, 변수의 타입을 "컴파일러"가 초기화식을 기반으로 자동으로 추론하도록 하는 기능을 제공한다. 예시를 먼저 보도록 하자. #include int main(void) { auto a = 3.14; // double auto b = 1; // int auto& c = b; // int& auto d = {0}; // std::initializer_list auto&& e = 1; // int&& auto&& f = b; // int& auto g = new auto(123); // int* const auto h = 1; // const int auto i = 1, j = 2, k = 3; // int, int, int auto l = 1, m = true,..
C++/Modern C++(11, 14, 17, 20)
2023. 8. 26. 18:12