The C ++ programming language supports various programming languages. Moreover, it has the object-oriented feature. In this article, we will introduce some basic concepts about C ++ variable declaration in detail. You can fully master the relevant knowledge.
- Detailed Usage Guide for C ++ member function pointers
- Overview of the basic content of the C ++ explicit keyword
- Basic concepts of the C ++ include Mechanism
- Summary of the Application Experience of C ++ traversal set
- Detailed description of C ++ assignment function code
Syntax for C ++ variable Declaration: extern int;
Syntax of the function declaration: extern int func1 (int length, int width );
Syntax for variable definition: int;
Function Syntax: int func1 (int length, int width ){}
The following are examples of C ++ variable declaration:
- //: 02: Declare. cpp
- // Declaration & definition examples
- Extern int I; // variable Declaration
- Extern float f (float); // function declaration
- Float B; // variable description and definition
- Float f (float a) {// Function Definition
- Return a + 1.0;
- }
- Int I; // variable definition
- Int h (int x) {// Function Description and definition
- Return x + 1;
- }
- Int main (){
- B = 1.0;
- I = 2;
- F (B );
- H (I );
- }/**////:~
C ++ variable declaration extension:
1. What should I declare first? : The Declaration tells the compiler "this function or this variable can be found somewhere and what it looks like ". In fact, all C/C ++ programs require declarations.
2. The definition can also be declaration.
3. extern can be omitted in function declaration.
4. Parameter identifiers are optional during function declaration.
5. In C ++, main () always returns the int type.
The above is an introduction to the C ++ variable declaration.