首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

异常:“a” was not declared in this scope

2012-03-12 
错误:“a” was not declared in this scope ?#includeiostream2 using namespace std34 int a56 int ma

错误:“a” was not declared in this scope ?
#include<iostream>
  2 using namespace std;
  3
  4 int a;
  5
  6 int main()
  7 {
  8 folat a=3.14;
  9 ::a=6;
 10 cout<<"local variable a="<<a<<endl;
 11 cout<<"global varible a="<<::a<<endl;
 12 return 0;
 13 }


错误在哪 求请教 小弟 新手望大家多多指教啊


[解决办法]
folat a=3.14;

float, 写错了
[解决办法]
还有最好这样写,float a = 3.14f;
3.14后面加一个f
[解决办法]

探讨

为什么要定义两个不同的a变量呢?另一个定义为b不好吗?

[解决办法]
把folat改成float就没有问题了。

热点排行
Bad Request.