|

楼主 |
发表于 2003-10-22 19:01:30
|
显示全部楼层
作为一名++的初学者,很荣幸大家对我提出的问题感兴趣。
quote from:
http://www.linuxquestions.org/qu ... amp;threadid=106915
- unsigned char* storage_a;
复制代码
这是一个dangling pointer (不好意思,我知道大多数人怎么翻译这个名词),
这个指针没有reference, 它试图把内存中的某处引领至stack,实际上stack中并没有它的信息,所以当我们试图获得这种指针的值时,程序崩溃。
我的问题:设,我把NULL赋值给两个没有reference的指针,pointer to int and pointer to char, 那么pinter to int的地址是:00000;pointer to char没有地址。这种观点对不对?
这里有一个程序:- #include<iostream>
- using namespace std;
- int main ()
- {
- unsigned char* uc;
- uc=0;
- unsigned int* ui;
- ui=0;
- double* ud;
- ud=0;
- cout<<"ui="<<ui<<endl;
- cout<<"ud="<<ud<<endl;
- cout<<"uc="<<uc<<endl;
- cout<<"builder"<<endl;
- }
- [root@localhost c_lib_test_a]# ./c_lib_test_ai
- ui=0
- ud=0
- uc=[root@localhost c_lib_test_a]#
复制代码
这个程序中的两个指针,double* ud and unsigned int* ui 是否具有相同的地址:00000? 到目前为止,在那个论坛里,还没有人回答我的这几个问题,我总是在论坛里问一些比较简单的问题。
谢谢。 |
|