There are five kinds of bracket characters in C: parentheses are used for function calls, conditional statements and control flow structures; square brackets are used for array/vector indexing and type conversion; curly brackets are used for code blocks; angle brackets are used for For template declarations and function overloading; parentheses are used to capture the variable list of a lambda expression.
Brackets in C
There are five bracket characters in the C programming language:
()
): used for function calls, conditional statements and control flow structures. []
): used for indexing and type conversion of arrays and vectors. {}
): used for code blocks (such as function bodies, loop bodies, and conditional statement bodies). <>
): used for template declarations and function overloading. ()
): Used to capture the variable list of the lambda expression. Parentheses
myFunction(arg1, arg2);
if (condition) { ... }
while (condition) { ... }
, for (initializer; condition ; increment) { ... }
square brackets
array[index];
vector[index];
static_cast<type>(expression);
Braces
Function body:
void myFunction() { // 代码块 }
Loop body:
while (condition) { // 代码块 }
Conditional statement body:
if (condition) { // 代码块 }
Angle brackets
template<typename T> class MyTemplate { ... };
int myFunction(int arg);
double myFunction(double arg);
Parents
Capture the variable list of the lambda expression:
auto myLambda = [](int& number) { // 访问捕获的变量 number };
The above is the detailed content of How to type square brackets in c++. For more information, please follow other related articles on the PHP Chinese website!