C++ keyword:
for
From cppreference.net
C++
C++ language
| General topics | ||||||||||||||||
| Flow control | ||||||||||||||||
| Conditional execution statements | ||||||||||||||||
| Iteration statements (loops) | ||||||||||||||||
|
||||||||||||||||
| Jump statements | ||||||||||||||||
| Functions | ||||||||||||||||
| Function declaration | ||||||||||||||||
| Lambda function expression | ||||||||||||||||
inline
specifier
|
||||||||||||||||
| Dynamic exception specifications ( until C++17* ) | ||||||||||||||||
noexcept
specifier
(C++11)
|
||||||||||||||||
| Exceptions | ||||||||||||||||
| Namespaces | ||||||||||||||||
| Types | ||||||||||||||||
| Specifiers | ||||||||||||||||
|
||||||||||||||||
| Storage duration specifiers | ||||||||||||||||
| Initialization | ||||||||||||||||
| Expressions | ||||||||||||||||
| Alternative representations | ||||||||||||||||
| Literals | ||||||||||||||||
| Boolean - Integer - Floating-point | ||||||||||||||||
| Character - String - nullptr (C++11) | ||||||||||||||||
| User-defined (C++11) | ||||||||||||||||
| Utilities | ||||||||||||||||
| Attributes (C++11) | ||||||||||||||||
| Types | ||||||||||||||||
typedef
declaration
|
||||||||||||||||
| Type alias declaration (C++11) | ||||||||||||||||
| Casts | ||||||||||||||||
| Memory allocation | ||||||||||||||||
| Classes | ||||||||||||||||
| Class-specific function properties | ||||||||||||||||
|
||||||||||||||||
| Special member functions | ||||||||||||||||
|
||||||||||||||||
| Templates | ||||||||||||||||
| Miscellaneous | ||||||||||||||||
Keywords
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Identifiers with special meaning | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
사용법
- for 루프: 루프의 선언으로서
|
(C++11부터) |
예제
이 코드 실행
#include <iostream> int main() noexcept { // 다음 'for' 루프 구문: // 1. (초기화문) 'i'라는 이름의 정수를 선언하고 값 '0'으로 초기화합니다. // 2. (조건문) i가 3보다 작은지 확인하고, 그렇지 않으면 루프 실행을 종료합니다. // 3. (실행문) 정수 'i'의 현재 값을 stdout에 출력합니다. // 4. (표현식) 정수 'i'를 전위 증가시킵니다 (값을 1 증가시킵니다). // 5. 포인트 2(조건문)로 돌아갑니다. // 초기화문: int i{0}; // 조건문: i < 3 for (int i{0}; i < 3; ++i) // 표현식: ++i std::cout << i; // 실행문: std::cout << i; }
출력:
012
참고 항목
|
(C++17부터) |
|
(C++23부터) |
-
switch
문:
switch,case -
default
(케이스 레이블 선언으로서)
등:
default -
goto
문:
goto -
continue
문:
continue -
break
문:
break -
return
문:
return
| (C++20 이후) |