Writing a Simple C++ Program
int main()
{
return 0;
}
A function definition has four elements: a return type,a function name,a(possibly empty)parameter list enclosed in parentheses,a function body.
Note
Note the semicolon at the end of the return statement.Semicolons mark the end of most statements in C++.They are easy to overlook but,when forgotten,can lead to mysterious compiler
error messages.
Key Concept:Types
Types are one of most fundamental concepts in programming and a concept that we will come back to over and over in this Primer.A type defines both the contents of adata element and the operations that are possible on those data.
The data our programs manipulate are stored in variables and every variable has a type.When the type of a variable named v is T, we often say that “v has type T”or,interchangeably,that “v is a T.”
本文介绍了一个简单的C++程序示例,解释了函数定义的基本组成部分,包括返回类型、函数名、参数列表及函数体,并强调了分号在C++语法中的重要性。
1397

被折叠的 条评论
为什么被折叠?



