【240809】C++的基础定义

160 阅读1分钟

参考资料

  1. 《Programming -- Principles and Practice Using C++ (3rd Edition)》—— Bjarne Stroustrup

C++ 基础定义

The notion of type is central to C++ and most other programming languages. Let’s take a closer and slightly more technical look at types:

  • A type defines a set of possible values and a set of operations (for an object).
  • An object is some memory that holds a value of a given type.
  • A value is a set of bits in memory interpreted according to a type.
  • A variable is a named object.
  • A declaration is a statement that gives a name and a type to an object.
  • A definition is a declaration that sets aside memory for an object.

Informally, we think of an object as a box into which we can put values of a given type. An int box can hold integers, such as 7, 42, and -399.