static function (process-oriented static keyword)

Source: Internet
Author: User

The function is defined as a static function by adding the static keyword before the return type of the function. A static function differs from a normal function in that it can only be seen in the file that declares it and cannot be used by other files.

Examples of static functions:

1#include <iostream>2 using namespacestd;3 4 Static voidFN ();//declaring static functions5 6 intMain ()7 {8 fn ();9       return 0; Ten } One  A voidFN ()//Defining static Functions - { -      intn = -; thecout <<n<<Endl;  -}

Benefits of defining static functions:

Static functions cannot be used by other files;

Functions with the same name can be defined in other files, and no conflicts occur.

static function (process-oriented static keyword)

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.