以下代码能够编译通过吗,为什么?
2012-06-29 16:45
211 查看
unsigned int
const size1
= 2;
char str1[ size1 ];
unsigned int temp
= 0;
cin >> temp;
unsigned int
const size2
= temp;
char str2[ size2 ];
答:str2定义出错,size2非编译器期间常量,而数组定义要求长度必须为编译期常量。
const size1
= 2;
char str1[ size1 ];
unsigned int temp
= 0;
cin >> temp;
unsigned int
const size2
= temp;
char str2[ size2 ];
答:str2定义出错,size2非编译器期间常量,而数组定义要求长度必须为编译期常量。
相关文章推荐
- 封装为什么能够提高代码的复用性
- 黑马程序员——写出以下代码执行结果,分析为什么?(没有分析结果不得分)
- Java入门学习-学会用txt文档写一段helloworld,并通过windows命令行编译和执行该Java代码
- 通过编译时注解生成代码实现自己的ButterKnife
- 请问这段安卓开发的代码不能通过编译的原因是什么
- 为什么C++编译器不支持模板头文件和实现代码分离的编译
- 编译通过的代码不算什么,一眼能看懂的代码才算好代码
- vc6.0转换为vs2008后代码编译不通过,error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...
- 在QtCreator中纯代码编写程序编译无法通过
- eclipse+cdt 代码编译通过 正常运行 编辑器却报错
- win7环境下,golang thrift demo代码编译不通过
- 用scanline取BMP上某点的颜色,代码如下,为什么可以编译,运行时却出错呢?
- Eclipse CDT 代码首次编译通过,第二次编译提示error: ld returned 1 exit status
- Arduino命令行编译 树莓派连接Arduino 电脑上编译Arduino代码后 通过树莓派烧写到Arduino上
- ubuntu12.04下常用软件的安装(代码编译可能缺少这些软件无法通过)
- 《剑指offer》在mac上编译通过的代码
- 以下代码中的输出语句输出0吗,为什么?
- C++中引用编译过的C代码为什么要用"extern c"
- 为什么继承是有害的?--通过把具体的基类转变成接口来改进你的代码
- android 更新代码之后 OpenCore 无法编译通过