小编Jam*_*mes的帖子

为什么我不能从用户读取值并使其成为常量?

输入以下代码后,我会收到错误.

const int quantity;
cout << "How much spacing do you want in-between the frames? " ;
cin >> quantity;
Run Code Online (Sandbox Code Playgroud)

错误:未初始化的const'数量'[ - fpermissive]

错误:'operator >>的模糊重载

如果我只使用int类型,就不会发生这种情况

int quantity;
cout << "How much spacing do you want in-between the frames? " ;
cin >> quantity;
Run Code Online (Sandbox Code Playgroud)

哪个编译没有问题.我是C++的新手,所以我想知道为什么会这样.

c++ iostream const

-1
推荐指数
1
解决办法
109
查看次数

标签 统计

c++ ×1

const ×1

iostream ×1