c++: the hint of pointer
来源:互联网 发布:繁体字转换软件 编辑:程序博客网 时间:2024/05/16 01:08
Okay.
Today i get a new concept about pointer:
I usually treat pointer as a tag of address. But now I think i made some mistakes.
First of all: when a pointer point to the the first of address (eg. array ), it obviously shows that the property of "index" or "offset". Its behavior represents you tell the hardware where the base address is, then when you try to operate it. the typical operation just likes the “add" and "minus" , it means the hardware should justice the next action, drift action show immediately.
Right now i know GNU C++ compiler which have this behaviors:
for instance:
// tacos[8]:: index(8) - tacos[1]::index(1) = 8 - 1 = 7, the result is 7....
# include <iostream>int main(){ using namespace std; int tacos[10] = {5,2,8,4,1,2,2,4,6,8}; int * pt = tacos; cout << "Pt's address: " << pt << endl; pt = pt + 1; cout << "Pt's address: ” << pt << " and " << * pt << endl; int * pe = & tacos[9]; pe = pe -1; // tacos[8]::index - tacos[1]::index = 1 int diff = pe - pt; cout << "pt's value: " << *pt << endl; cout << "pe's value: " << *pe << endl; cout << "diff's value: " << diff << endl; return 0;}
- c++: the hint of pointer
- The pointer of function
- the application of pointer
- The amazing efficiency of pointer in C Programming Language
- the type of a pointer
- C column of Pointer <0>
- C column of Pointer <1>
- C column of Pointer <2>
- C column of Pointer <2> malloc() free()
- C column of Pointer <3> malloc() free()
- How to use the pointer of function in a class?
- Relationship of the this pointer and (non-)const member function
- [Swift] function pointer(address) as the parameter of function
- The function that returns the pointer (C Programming)
- Is the type of “pointer-to-member-function” different from “pointer-to-function”?
- A pointer to an object & A pointer one past the end of a different object
- cast of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __C
- c pointer
- android的智能指针
- memcpy和strlen函数的实现
- Coroutines in C
- HDU1969---Pie 二分
- 字符串hash函数
- c++: the hint of pointer
- poj 1226 Substrings(二分 + kmp)
- Problem 1056 - 函数问题 ---三分法
- 远程提交Map/Reduce任务
- poj 2185 Milking Grid(最小矩阵覆盖,二维 kmp 匹配)
- mysql show columns等show的用法
- 关于斯特方码
- linux c使用互斥锁实现同步
- HTML5做手机站页面字体显示很小的解决方法