views:

61

answers:

1

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?

+4  A: 

your FILE needs to be a pointer to FILE

FILE *pipe;

then

pipe = popen(...)

Matt Greer
Tried with *pipe, but it gives the same error as mentioned above.
Paul
Update: My bad. Works now. Thanks a lot! :)
Paul