main 함수
- 모든 C++ 프로그램에 반드시 main 함수가 포함되어야 한다.
- main 함수의 패러미터가 없을때 공란으로 둘 수 있지만 void 키워드로 패러미터가 없음을 명시할 수도 있다.
#include <iostream>
int main(void)
{
std::cout << "Hello World!" << std::endl;
return 0;
}
Statements, Expressions
- return 0; 와 같이 순차적으로 실행되는 C++ 프로그램의 부분을 Statements라고 한다. 번역을 할때는 일반적으로 명령문, 문장이라고 부른다.("Statements are fragments of the C++ program that are executed in sequence." - cppreference.com)
- 1 + 1, func(argument), "Hello World" 같이 연산을 특정하는 연산자와 피연산자 나열을 Expressions라고 한다. 번역할때는 주로 표현식이라고 부른다. ("a sequence of operators and operands that specifies a computation" - cppreference.com)
- 둘을 구분하기는 쉽지 않지만 실행 여부가 중요하다. func(arg)는 expressions이지만 func(arg); 은 statements다.
Expressions - cppreference.com
An expression is a sequence of operators and their operands, that specifies a computation. Expression evaluation may produce a result (e.g., evaluation of 2+2 produces the result 4), may generate side-effects (e.g. evaluation of printf("%d",4) sends the ch
en.cppreference.com
Statements - cppreference.com
Statements are fragments of the C++ program that are executed in sequence. The body of any function is a sequence of statements. For example: int main() { int n = 1; // declaration statement n = n + 1; // expression statement std::cout << "n = " << n << '\
en.cppreference.com