[debug]*pAge=&howOld是错的
发布于 2006-01-25 11:58 2 阅读:40,365 评论:2 标签: C++

    书上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:06
Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 154

Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 172
比较低级的错误了

by 2007-10-26 10:49:59
Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 154

Warning: Trying to access array offset on value of type bool in /opt/bitnami/apache/htdocs/workingsmarty/templates_c/e21e83752348f01f75c472238af0e4512d51cc32_0.file.left_look.html.php on line 172