name lookup of 'res' changed for new ISO 'res' scoping
来源:互联网 发布:网络编程。tcp udp视频 编辑:程序博客网 时间:2024/04/30 14:26
#include<iostream>
using namespace std;
int pow ( int val, int exp );
int main()
{
int val = 2;
int exp = 10;
cout << pow ( val, exp ) << endl;
}
int pow( int val, int exp )
{
for ( int res=1 ; exp > 0; exp-- )
res = res * val;
return res;
}
在linux下用g++编译会出现如下错误:
error: name lookup of ‘res’ changed for ISO ‘for’ scoping
note: (if you use ‘-fpermissive’ G++ will accept your code)
它说的是 for 循环中在 “初始化”部分 定义的变量的作用域范围的一个问题。ISO/ANSI C++ 把在此定义的变量的作用域范围限定在 for 循环体 内,或者说,出了循环体之外这个变量就无效了。可以使用‘-fpermissive’使编译通过。
应该把红色部分改成:
int res;
for ( res=1 ; exp > 0; exp-- )
0 0
- name lookup of 'res' changed for new ISO 'res' scoping
- name lookup of `i' changed for new ISO `for' scoping
- error:name lookup of "c1 "changed for ISO 'for' scoping
- error: name lookup of 'first' changed for ISO 'for' scoping [-fpermissive]
- 自学QT之报错: name lookup of 'i' changed for ISO 'for' scoping
- c++编译错误提示[Error] name lookup of 'i' changed for ISO 'for' scoping
- Qt中"look up 'i' Changed for ISO 'for' scoping" 错误及解决
- res
- res
- res
- res
- 一般c++编译出现"name lookup of '变量名' changed [enabled by default]"的警告
- java面试题:res初值为0,接着for循环10次后,res+=res++?最后res等于多少
- Name lookup for Class Member Declarations
- android 报错:invalid resource directory name bin/res/crunch
- android 报错:invalid resource directory name bin/res/crunch
- RES协议
- Res 协议
- poj 2828 Buy Tickets (线段树)
- 应届毕业生,让人欢喜让人忧
- POJ 1017 Packets
- javaIO删除文件夹
- 【BZOJ】【P1475】【方格取数】【题解】【最小割】
- name lookup of 'res' changed for new ISO 'res' scoping
- C# 中(int),Int32.Parse() 和Convert.toInt32用法[转载]
- linux 下开放指定端口
- 集训总结---第一天
- centOS下安装mysql
- 1407231910-hd-Problem E.cpp
- 单链表的运算实现
- SecureCRT设置及快捷键
- memcache的安装及管理