Analysis of C ++ variable declaration concepts

Source: Internet
Author: User

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:

 
 
  1. //: 02: Declare. cpp
  2. // Declaration & definition examples
  3. Extern int I; // variable Declaration
  4. Extern float f (float); // function declaration
  5. Float B; // variable description and definition
  6. Float f (float a) {// Function Definition
  7. Return a + 1.0;
  8. }
  9. Int I; // variable definition
  10. Int h (int x) {// Function Description and definition
  11. Return x + 1;
  12. }
  13. Int main (){
  14. B = 1.0;
  15. I = 2;
  16. F (B );
  17. H (I );
  18. }/**////:~

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.