Valid c ++ Study Notes

Source: Internet
Author: User

Valid c ++ Study Notes

Clause 1:

 

The C ++ language can be seen as a mixture of multiple sub-languages.

1,C

2,Template

3,STL

4,Class

 

Clause 2:

 

1,For simple constants, such as constants that declare the length of an array in a class, you can use

ENum{}, You can use

Constexpr static or const staticTo replace,

 

2,# Define cannot support encapsulation., Avoid as much as possible, of course, like

# Ifdef, # endif Still useful (the compiler will directly replace the macro used)

 

3. Use inline to replace macros such as functions (otherwise, many side effects will occur)

 

Clause 3:

 

1. Many functions return a constant value of const to avoid unreasonable operations on the returned value, such

Class {}

Const A operator * (const A & x, const A & y );

Without a const, it is possible to perform a meaningless value assignment operation on the function return value.

 

 

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.