What is an object? (Page 238)
In C++, an object is just a variable, and the purest definition is "a region of storage" (this is a
more specific way of saying, "an object must have a unique identifier," which
in the case of C++ is an
unique memory address). It‘s a place where you can store data, and it‘s
implied that there are also operations that can be performed on this data.
Empty structure in C++ (Page 241)
In C, the empty structure is illegal, but in C++ we need the option of
creating a struct whose sole task is to scope function names, so it is allowed.
So structures with no data members will always have some minimum
nonzero size.
Header file etiquette
What you can put into header file. (Page 244-245)
The basic rule is "only
declarations," that is, only information to the compiler but nothing
that allocates storage by generating code or createing variables.
The second header-file issue is this: when you put a struct declaration in a
header file, it is possible for the file to be included more than once in a
complicated program. Both C and C++ allow you to redeclare a function, as long
as the two declarations match, but neither will allow the redeclaration of a
structure. We can use the preprocessor directives "#define #ifdef #endif" to
solve the problem.
Global scope resolution (Page 253)
::
If you want use a global
variable in a function, but there is a same named variable in the function. The
compiler would default to choosing the local one. So you can specify a global
name using scope resolution "::".
Data Abstraction,码迷,mamicode.com