C++ 如何从C++;程序

C++ 如何从C++;程序,c++,gnuplot,C++,Gnuplot,下面是我用来将数据(x和y坐标)写入文件的代码 void display(){ fstream out; outfile.open("Co_ordinates.txt",fstream::out | fstream::trunc); outfile.precision(6); for(int i=0;i<3000; i++){ outfile<<fixed<<x[i]<<" "<<fixe

下面是我用来将数据(x和y坐标)写入文件的代码

void display(){

    fstream out;
    outfile.open("Co_ordinates.txt",fstream::out | fstream::trunc);
    outfile.precision(6);
    for(int i=0;i<3000; i++){
        outfile<<fixed<<x[i]<<"   "<<fixed<<y[i]<<endl;
    }
    out.close();

}
我添加了以下代码来绘制图表

const string s="Co_ordinates.txt";
Gnuplot& plotfile_xy(&s,1,2,'Grid');
但是会出现以下错误

错误:表达式列表在初始值设定项[-fppermissive]中被视为复合表达式| 错误:从“int”类型的右值初始化“Gnuplot&”类型的非常量引用无效|

我已经用几种形式尝试了上述代码。。但是会有错误。
请提出一些解决办法

plotfile_xy
Gnuplot
类的成员函数,因此要调用它,您需要一个
Gnuplot
的实例,例如:

Gnuplot gp("lines");
//using the parameters from your code
gp.plotfile_xy(&s,1,2,'Grid');
文档方面没有太多内容,但是您是否注意到有一个示例程序演示了很多函数?

我所做的全部工作都可以使用以下代码轻松完成


system(“gnuplot-p-e\'plot'coordinates.txt'\”)我认为您编写的
Gnuplot&plotfile_xy(&s,1,2,'Grid'),编译器认为您是在声明函数,而不是调用函数。
Gnuplot gp("lines");
//using the parameters from your code
gp.plotfile_xy(&s,1,2,'Grid');