notes of c++ primer (2)
来源:互联网 发布:linux退出vim 编辑:程序博客网 时间:2024/06/05 02:13
The C++ Data Types
Pointer Types
1、Every pointer has an associated type. The difference between pointers of different data types is neither in the representation of the pointer nor in the values (addresses) the pointers may hold— these are generally the same for all data pointers. The difference, rather, is in the type of the object being addressed. The type of a pointer instructs the compiler how to interpret the memory found at a particular address as well as how much memory that interpretation should span.
2、Of course, if all we wish to do is to hold the address value (and possibly compare the address value to a second address value), then the actual type of the pointer does not matter. A special pointer type is provided to support just that: the void* pointer can be assigned the address value of any data pointer type (a function pointer cannot be assigned to it).
String Types
C++ provides two string representations: the C-style character string and the string class type introduced with Standard C++.
The C-Style Character String
1、The string is stored within a character array and is generally manipulated through a char* pointer.
2、The character pointer addressing a C-style string always refers to an associated character array.
3、Internally, the system stores the string literal within a character array.
string Type
1、 The string type is capable of automatically converting a C-style character string into a string object. This allows us, for example, to assign a C-style character string to a string object:
2、In order to converte a string object into a C-style character string, we must explicitly invoke the oddly named c_str() operation:
c_str() returns a pointer to constant array in order to prevent the array from being directly manipulated by the program.
- notes of c++ primer (2)
- notes of c++ primer (1)
- C++ Primer notes
- notes of c++ primer (3) -- const的那些事
- Notes 2 of 《Beauty of Mathematics》
- C++ Primer Notes(6)
- C++ Primer Notes(13)
- C++ Primer Notes(14)
- C++ Primer Notes(16)
- C++ Primer Notes
- notes of c++ primer (4) -- 纠结的虚函数表 之一
- notes of c++ primer (5) -- 纠结的虚函数表 之二
- Notes of Flash Builder 4 Bible (2)
- Notes of Python Learning 2/10/2016
- Notes of Py for informatics 2
- C primer Plus2-2
- C Primer Plus3-2
- C Primer Plus4-2
- 李开复:成长中的十个启发
- Ext.apply() 和Ext.applyif()的内部机制问题
- DB2应用数据库配置
- 为了测试积分的增长
- 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的
- notes of c++ primer (2)
- 数据库SQLSERVER2005EXPRESS版本命令符方式附加数据库
- 怎么长积分啊!
- 厌倦了流浪,却找不到归属
- Intent机制学习笔记
- SQLSERVER2005EXPRESS版本的静默安装
- AutoESL AutoPilot : Customers
- redo文件丢失处理方法
- 按第一学期、第二学期、第三学期、……第十学期排序的SQL语句