C ++ programming ideology-naming Control

Source: Internet
Author: User

1. Static
The static object destructorProgramIt is called only when exiting from the main () block or when the standard C library function exit () is called. This means that using exit () inside the Destructor is dangerous.
You can use atexit () to specify the operations that should be performed when the program jumps out of main () or calls exit.
If a function containing a static object has not been called, The destructor of this object will not be executed.
Within the file range, the name of an object or function explicitly declared as static is a local variable for the compilation unit.

A local class (a class defined inside a function) cannot contain static data members.

2. namespace
Namespace can only be defined globally, but they can be nested with each other.
A namespace can be used as its alias.
Example: namespace adafadfadfa {......}
Namespace A = adafadfadfa;
Using is used to introduce namespace.

3. Specify the conversion connection
1) extern "C" fun ();
2) extern "C "{
Fun1 ();
Fun2 ();
}

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.