开发者

Using pipes inside a class in C++

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜