C ++ primer Study Notes (2): basic language 2

Source: Internet
Author: User

Source: C ++ primer P49 ~ 67
Level: 100

 

Const int I, j = 0;
Note: constants must be initialized during definition.

 

Extern const int bufsize = 100;
Note: The const variable declared in the global scope is an internal object by default. After the extern is added, it can be accessed across compilation units.

 

Int & refval = ival;
Note: After Non-const references are initiated, they are always bound to this object. And the type must be the same as the bound object.

 

Double dval = 1.1;
Const Int & rI = dval;
Note: const references can be bound to different but related types.

 

Enum points {point2d = 2, point2w, point3d = 3, point3w}; // 2, 3, 3, 4
Points pt2w = 3; // Error
Note: The value assignment is invalid even if 3 is a value in the points enumeration.

 

Class sales_item {};
Note: The class definition is followed by a semicolon.

 

The only difference between class and struct keywords
Note: by default, the struct member is public and the class member is private.

 

The header file should not contain definitions.
Note: three exceptions: Definition class, const object, and inline function.

 

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.