1. the compiler does not check the length of the real parameter Array
2. Pass the array through reference
Void printvalues (INT (& ARR) [10]) {/**... **/}
The compiler checks the size of real parameters.
3. Main: process command line options
Code:
- # Include <iostream>
- Using NamespaceSTD;
- IntMain (IntArgc,Char** Argv)
- {
- If(Argc! = 3)
- {
- Cout <"Please input 3 ARGs! ";
- }Else{
- Cout <"Sum :"<Atof (argv [1]) + atof (argv [2]);
- }
- }
======================================== 4.20 update ================== ========================
The second parameter defines a C-style string array.
The first parameter defines the number of strings in the array.
======================================== 4.24 update ================== ========================
Array as reference parameter
A parameter is used to replace the array name (& ref) in the array definition. The array size must be specified. For example:
int fun (INT (& ARR) [10]);
Note: (& ref) there must be no less parentheses on both sides. Otherwise, Int & arr [10] indicates an array with 10 referenced elements (note: the element type cannot be defined as a referenced array in C ++ ).