书上142页有一个语句:
unsign short int howOld = 50;
unsign short int *pAge = 0;
*pAge = &howOld;
初看一眼,还以为这又是C与C++的区别。今天急忙编译了一下,发现这又是书上的错误。编译器提示:invalid conversion from `int*' to `int'
附程序:
/*********************************************
*Developer: yayu; *
*My email: xieyayu@163.com *
*Development environment: Dev-C++ 4.9.9.0; *
*********************************************/
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
int *page=0;
int age=100;
*page=&age;
//page=&age;
//*page=age;
cout<<"*page is : "<<*page<<endl;
cout<<"page is : "<<page<<endl;
return 0;
}
指针的用法是C程序员的必修课。
by PESoft 2008-01-03 12:50:06by 2007-10-26 10:49:59