Differences between variable declaration and definition

Source: Internet
Author: User

Crazyspopcorn

Not to mention the direct focus:

If you divide a program into multiple files, you need to include code in some files. For example, a header file is contained in another header file, if a variable is defined as 2 .. Errors reported by the compiler

Error variable redefinition I believe many people have seen

Variable Declaration

Specifies the type and name of the variable. The definition is the same as that of the variable. However, in addition, the definition also applies for a bucket, and the variable may be assigned an initial value;

If you want to declare a variable rather than define it, add the keyword extern before the variable name and do not display the value of the initialization variable.


Extern int I; // declare I instead of defining I. No memory space is allocated for Int J; // declare and define J and allocate space for J



Differences between variable declaration and definition

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.