Some C + +

Source: Internet
Author: User

1.static Static local objects:

Once created, it will not be revoked until the end of the program. When a function that defines a static local object ends, the static local object is not undone.

2. Inline functions:

Avoid the overhead of function calls.

With the keyword inline before the function return type, you can designate some specific functions as inline functions.

3. Friend £ º

The friend mechanism allows a class to grant access to its non-public members to the specified function or class.

4.static Class Members:

Static data members exist independently of any object of the class. Each static data member is an object associated with a class and is not associated with an object of that class.

The static member function does not have the This parameter, it can directly access the static member of the owning class, but cannot use the non-static member directly.

Three advantages:

(1) static member names in the scope of the class, you can avoid conflicts with other global object names.

(2) encapsulation can be implemented. Static can be a private member.

(3) The program is clearer and static members are associated with a particular class.

Note: The static member function cannot be declared as Const. The static member function cannot be declared as a virtual function.

5. Dynamic binding:

When a virtual function is called by a reference to a base class or by a pointer, it dynamically determines the operation of the virtual function according to the base class object or derived class object to which it points.

Triggering a dynamic binding satisfies two conditions:

(1) Only member functions that are specified as virtual functions can be dynamically bound.

(2) A function call must be made through a reference to a base class type or a pointer.

6. Pure virtual function:

Defining a function as a pure virtual function can explain that the function provides an interface that can be overridden for descendant types, but the version in this class is never called.

7. Smart pointers:

Reference count, the audit reference count at the time of Destruction, is not released until 0 o'clock.

8. Polymorphism:

One interface, multiple states.

is implemented by virtual functions.

9. Singleton mode:

The intent is to ensure that a class has only one instance and provides a global access point to access it, which is shared by all program modules.

Some C + +

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.