Register variable extern external variable external function, register extern

Source: Internet
Author: User

Register variable extern external variable external function, register extern

Register variable

Ignore this.

Variables defined by the register keyword are directly placed in registers.

A register is a storage unit placed inside the CPU. It is much faster than the memory, so when the program calls the same variable for more than 10000 times, it is declared as a register variable, which will increase the execution speed of the program.

Technology development does not need to write register int I, f = 1;

 

Use the keyword extern for external variables

View results?

# Include <iostream> using namespace std; int fun (int x, int y); int main () {extern int a, B; cout <fun (a, B) <endl; return 0;} int a = 15, B =-7; int fun (int x, int y) {int c; c = x> y? X: y; return c ;}

External Functions

# Include <iostream> using namespace std; int fun (int x, int y); int main () {extern fun (int x, int y ); // The method int a = 15, B =-7; cout <fun (a, B) <endl; return 0;} in the external program is called ;}

Int fun (int x, int y) {int c; c = x> y? X: y; return c ;}

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.