首页 > 编程语言 > 详细

C++ primer (study notes)

时间:2021-04-08 10:05:14      阅读:29      评论:0      收藏:0      [点我收藏+]

Chapter 2

2.2 Variables

  • Initialization

    Initialization is not assignment
    Initialization happens when a variable is given a value when it is created. Assignment obliterates an object’s current value and replaces that value with a new one.

    For default initialization,variables of build-in type outside any blocks are initialized to zero, while inside function body being uninitialized. Class types have different initialization rules.

  • Declarations and Definitions

    Variables must be defined exactly once(in one file) but can be declared many times(in other files).

  • Scope

    Names are available from the point where they are declared until the end of the scope in which the declarations appears. For example, names defined in for-statement can only used in that statement.

  • Reference
    A reference is not a object, it‘s just another name for an already existing object.Use ‘&‘.

    Because references are not objects, we may not define a reference to a reference.

C++ primer (study notes)

原文:https://www.cnblogs.com/bntodo/p/c-primer-study-notes.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!