码迷,mamicode.com
首页 > 其他好文 > 详细

Data Abstraction

时间:2014-05-01 04:38:01      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:com   style   code   c   t   size   sp   color   int   ble   re   

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

Data Abstraction

标签:com   style   code   c   t   size   sp   color   int   ble   re   

原文地址:http://www.cnblogs.com/ruccsbingo/p/3702059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!