错误“'使用'之前的预期初始化程序”C++

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21997706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 23:53:43  来源:igfitidea点击:

error "expected initializer before 'using'" c++

c++

提问by user3316789

im new here ,and new at proggraming in general . whem im trying to run this code:

我是新来的,一般是编程方面的新人。我正在尝试运行此代码:

#include<fstream>
#include <iostream>
#include "main.h"
using namespace std;
int main()
{
 short arr_size ()
float temp;
point point_arr[99];
ifstream my_file   ("points.txt");
while(!my_file.eof())
{
    my_file>>temp ;
    point_arr[arr_size].set_x(temp);
    my_file>>temp ;
    point_arr[arr_size].set_y(temp);
    arr_size++;
}
arr_size--;
my_file.close();
ex_point(point_array,arr_size);
cout<<"the middle point is:("<<mid_p(point_array,arr_size).get_x()<<","<<mid_p(point_array,arr_size).get_y()<<")\n";
return 0;
}

im getting this error : "error "expected initializer before 'using'" c++" this is the first time i get this error . it may be somthing wrong with "main.h" ? this is "main.h " :

我收到此错误:“错误”在‘使用’之前的预期初始化程序”c++”这是我第一次收到此错误。“main.h”可能有问题?这是“main.h”:

    #ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
#include<iostream>
class point
{
    float x ,y ;
public :
    point(float a,float b){x=a;y=b;}
    point(){};
    void set_x(float a){x=a;};
    void set_y(float b){x=b;};
    const float get_x(){return x; };
    const float get_y(){return y; };
    const void show();
    const float pitagoras();
};
const point mid_p(point[],float);
const void ex_point(point[],float)



#endif // MAIN_H_INCLUDED

thank you ! ivory

谢谢你 !象牙

回答by Brian

const void ex_point(point[],float)

at the end of main.his missing a semicolon.

末尾main.h缺少分号。