开发者

Using pipes inside a class in C++

开发者 https://www.devze.com 2022-12-27 09:47 出处:网络
I\'m trying to use this tutorial to make plots with Gnuplot in C++. However I will be using the pipe to Gnuplot from within a class, but then I run into some problems:

I'm trying to use this tutorial to make plots with Gnuplot in C++. However I will be using the pipe to Gnuplot from within a class, but then I run into some problems:

I've got a header file where I declare all variables etc. I need to declare the pipe-variable here too, but how do I do that?

I've tried doing it straight away, but it doesn't work:

Logger.h:

class Logger {
   开发者_如何学编程 FILE pipe;
}

Logger.cpp:

Logger::Logger() { //Constructor
    *pipe = popen("gnuplot -persist","w");
}

Gives the error Logger.cpp:28: error: no match for ‘operator=’ in ‘*((Logger*)this)->Logger::pipe = popen(((const char*)"gnuplot -persist"), ((const char*)"w"))’

Suggestions?


your FILE needs to be a pointer to FILE

FILE *pipe;

then

pipe = popen(...)

0

精彩评论

暂无评论...
验证码 换一张
取 消