"declaration has no storage class or type specifier" C++
"declaration has no storage class or type specifier" in C++
我正在通过书(第5版(学习C ,今天我在练习12.6时遇到问题。
代码如下所示,错误是this declaration has no storage class or type specifier
。但是该程序可以正常运行。错误位于'}'的最后一行。
#include<iostream>
#include<vector>
#include<new>
using namespace std;
vector<int>* func(){
return new vector<int>();
}
void read_vec(istream &in, vector<int>* vp){
int i;
while(in>>i)
vp->push_back(i);
}
void print_vec(vector<int>* vp){
for(int i:*vp)
cout<<i<<" ";
cout<<endl;
}
int main(){
auto vec = func();
cout<<"Enter a sequence of integers"<<endl;
read_vec(cin,vec);
print_vec(vec);
delete vec;
vec = nullptr;
system("pause");
}
我已经搜索了该消息,但仍然无法弄清楚我的代码在哪里错误。
我将感谢所有提示。
您需要标准库标题<cstdlib>
才能使用system
。
添加
#include <cstdlib>
在文件的顶部。然后,使用std::system
而不是system
。
std::system("pause");
相关文章:
- "Missing type specifier - int assumed"无法通过向主函数添加"return 0"来解决
- 由于"error C4430: missing type specifier - int assumed. Note: C++ does not support default-int",我现在无法编
- C++ 结构数组 - "This declaration has no storage class or type specifier"
- 警告"C++ requires a type specifier for all declaration"地图
- C++ 中的"this declaration has no storage class or type specifier"错误
- 如何修复派生类给出错误'declaration has no storage class or type specifier'?
- "declaration has no storage class or type specifier" C++
- 级运算符 ( "C++ requires a type specifier for all declarations" )
- 为什么我有"Expected type specifier error"?
- 柯尼希查找和"C++ requires a type specifier for all declarations"
- C++ 另一个标头中的结构函数给出"missing type specifier"
- 默认模板参数结果为"expected type-specifier"
- 编译错误 C++ "was not declared in this scope" "expected type specifier"等
- Qt:"Expected type-specifier"出现在一台设备上,而不是另一台具有相同代码的设备上
- 错误"this declaration has no storage class or type specifier"
- 在同一函数中"this declaration ahs no type specifier"和"expected a declaration"错误
- 使用字符串流时出现"Declaration has no storage class or type specifier"错误
- 在另一个类声明中创建类的对象时"Expected a type specifier"错误
- 在自定义类中实例化自定义类时出现"expected type-specifier"错误
- 错误"C++ requires a type specifier for all declarations"