我有以下代码
在 C 中
int main()
{
const int k;//allowed but garbage and later we can't modify
printf("%d",k);
}
o/p=垃圾
在 C++ 中
int main()
{
const int k; //not allowed from here itself
printf("%d",k);
}
o/p-编译时错误
我怀疑如果要在没有声明的情况下声明它,但在它之后我们不能声明它,const那么 in C的用途是什么。allowedinitializationdeclarationinitialize
但是c++我们不能在const没有initialization.
里面的变量有什么用k还是C没用,如果我们只声明它,因为以后修改是不可能的。