高质量程序设计指南c++/c语言(12)--指针

      指针的类型为一个类型名和一个字符“*”的组合,虽然类型名和“*”的组合是一种指针类型,但是编译器解释的时候,“*”是和其后的变量名结合的。例如:

      int* a,b,c;

编译器理解为:

      int *a, b,c;

即只有a是int类型的指针,而b和c仍然是int类型的变量。指针的值是int类型的,可以赋给它任何整数值,包括负数

#include<iostream>
using namespace std;


int main(void)
{
    int *pInt = NULL;
    pInt = reinterpret_cast<int *>(-0x0024FFE4);
    cout << pInt << endl;
    cout << reinterpret_cast<unsigned int>(pInt) << endl;
    cout << UINT_MAX << endl;

    return 0;
}

输出:

FFDB001C
4292542492
4294967295
可见编译器把指针解释为unsigned int型数据。

posted on 2013-04-27 16:00  江在路上2  阅读(148)  评论(0编辑  收藏  举报