const可以用于聚合
编译器不会把一个聚合保存到它的符号表中,要分配内存
const意味着 不能改变的一块存储空间
const不能再编译器使用值
编译器不知道存储的内容
//: C08:Constag.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 2000
// Copyright notice in Copyright.txt
// Constants and aggregates
const int i[] = { 1, 2, 3, 4 };
float f[i[3]]; // Illegal
//error C2057: 应输入常量表达式
//error C2466: 不能分配常量大小为 0 的数组
struct S { int i, j; };
const S s[] = { { 1, 2 }, { 3, 4 } };
double d[s[1].j]; // Illegal
//error C2057: 应输入常量表达式
//error C2466: 不能分配常量大小为 0 的数组
int main() {} ///:~
代码非法
数组定义里,编译器必须能产生代码,移动栈指针来存储数组
提示是因为它不能在数组定义里找到一个参数表达式
通不过编译