错误:error: expected identifier before numeric constant

我一开始定义二维数组初始化的时候,我是这样写的:

vector<vector<int> > v(501,vector<int>(501,0));

编译器给我报错:
在这里插入图片描述

error: expected identifier before numeric constant


应该可以这样修改:
vector<vector<int> > v=vector<vector<int> >(501,vector<int>(501,0));

我这样修改之后编译就通过了。

应该是需要我们在声明的时候需要在写一遍我们要赋值的类型,这样编译器才知道如何赋值。



感谢大家对文章的支持!
如果此文对你有帮助,可以给博主三连+关注,你的支持是博主创作历程中最大的动力~~~!

猜你喜欢

转载自blog.csdn.net/xiatutut/article/details/125724437
今日推荐