Dev-C++ 4.9.9.0在for中的定义为局部变量
发布于 2006-01-23 12:24 2 阅读:43,068 评论:2 标签: C++

  程序将提示:

     D:\yayu\C++Test\forDeZuoYongYu.cpp In function `int main(int, char**)':

    21 D:\yayu\C++Test\forDeZuoYongYu.cpp name lookup of `i' changed for new ISO `for'  scoping

    16 D:\yayu\C++Test\forDeZuoYongYu.cpp   using obsolete binding at `i'

     D:\yayu\C++Test\Makefile.win [Build Error]  [forDeZuoYongYu.o] Error 1

附程序:

/*********************************************
*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 i; 
   
  for(int i=0 ; i<5 ; i++)
  {
    cout<<"i : "<<i <<endl;
  }
   
  i=7;
 
  return 0;
}

一点小更正

DEV在内部使用的是MinGW做为编译器的。所以标题应该改为:
MinGW在for语句中的定义的变量为局部变量
如果喜欢这种简单的开发环境介意使用:CodeBlocks集成开发环境。
或者你也可以使用某一种“文本编辑器”+MinGW自己配置!

by pesoft 2008-01-03 12:46: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
在这一点上Dev-C++是支持C++标准的

在for之中定义的变量,那么它的作用域应该是for的循环体之中。
可惜VC中一直对这个标准的支持不够。

by 李马 2006-01-24 09:28:00
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