类型说明符错误 [英] type specifier error

查看:178
本文介绍了类型说明符错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  #include< iostream> 

using namespace std;
int b = 10;
// b = 100;
int main(int argc,char * argv [])
{
cout<< b<< endl;
return 0;
}

如果删除 b = 100 。为什么这样。输出为10否则。
错误:C ++需要所有声明的类型说明符。

解决方案

全局范围只能包含声明和定义,不是任意语句。



C ++认为您正在尝试声明和定义另一个变量 b

#include <iostream>

using namespace std;
int b=10;
//b=100;
int main(int argc, char *argv[]) 
{
   cout<<b<<endl;
   return 0;
}   

There is an error if remove the comment at b = 100.Why is that so.The output is 10 otherwise. error:C++ requires a type specifier for all declarations.

解决方案

The global scope can only contain declarations and definitions, not arbitrary statements.

C++ thinks you're trying to declare and define another variable called b.

这篇关于类型说明符错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆