类型声明错误
Error with type declaration
我一直得到错误"此声明没有存储类或类型说明符。"我已经检查了分号,并包含了相关的库。
#include <iostream>
#include <fstream>
using namespace std;
const int n = 8;
double p[n] = {1.23, .97, .86, .77, .69, .65, .71, .50};
double pi[n] = {.74, .70, .66, .68, .65, .62, .60, .54};
double z[n] = {.25, .35, .45, .55, .65, .75, .85, .95};
ofstream myfile;
myfile.open("ppilow.txt"); //Error here
尝试用以下代码替换myfile.open("ppilow.txt");
:
int main(int argc, char *argv[])
{
myfile.open("ppilow.txt");
return 0;
}
说明:你不能把指令放在函数体之外。
但是最好避免声明全局变量,所以我建议你也把它移到body中
相关文章:
- 错误:未在此范围内声明'reverse'
- C++错误C2600:无法定义编译器生成的特殊成员函数(必须首先在类中声明)
- 从具有默认值的部分指定模板类继承时发生SWIG错误,具有不带默认值的正向声明
- 错误:"imread"未在此范围内声明
- 在气泡排序程序中未声明错误功能
- 使用全局声明的向量时,C++双重释放错误/损坏
- 使用直接大括号初始化时,C++ 编译错误"声明末尾的预期";"
- C++ [错误] 声明'char '隐藏参数。什么意思?
- 类中的静态函数给出了错误:声明中的两种或多个数据类型
- 错误:声明冲突 - 指针不能是 int
- 收到 CUDA 错误"声明与以前的"variable_name"不兼容
- 错误:声明不声明
- Visual Studio 2010 链接器错误C++声明我从头文件创建的类时
- Cython 错误:声明不声明任何内容
- 错误"声明非模板函数"C++
- 无效地使用不完整的类型/前向错误声明.可能误用抽象类?(c++)
- 错误:声明冲突.用c++编译c代码
- C++错误:声明中存在显式限定
- else语句(C++)上的错误w/声明
- 初始化const类成员,错误:声明没有声明任何内容