ofstream error with operator<<

Hi,
I am writing a macro for a program called ROOT (big physics library/analysis package type thing)(I'm pretty sure the error is C++ related rather than ROOT-related). In one of my functions I am getting an error with the operator<< with an ofstream variable. The function is as follows:

void display(ofstream* out,double* data){
out << setfill(' ') << setw(12) << numFormat(data[0]/2.54,4);
out << setfill(' ') << setw(12) << numFormat(data[1]/2.54,4);
out << setfill(' ') << setw(12) << numFormat(data[2]/2.54,4);
out << setfill(' ') << setw(12) << numFormat(data[3]/2.54,4);
out << setfill(' ') << setw(5) << numFormat(data[4]/2.54,1);
out << setfill(' ') << setw(5) << numFormat(data[5]/2.54,1);
out << setfill(' ') << setw(5) << numFormat(data[6]/2.54,7);
out << setfill(' ') << setw(2) << numFormat(data[7],0) << endl;
}

(numFormat is a separate function defined elsewhere that has nothing to do with the problem (it returns a string with the number formatted in the way that I need it)).

I call the function with:
display(&fout,lineData);
fout is of type ofstream and has a file open. lineData is an array of doubles with length 10.

When I tell ROOT to run it (ROOT uses an interpreter so you give it the code rather than a compiled program), I get this error:

Error: operator<< not defined for basic_ofstream<char,char_traits<char> > C:\Users\Tyler\Desktop\GDML_convert.cpp(493)

Line 493 is the line immediately following '{'.

Any idea what is going wrong here?

Thanks,
-Tyler

because you are passing a pointer to an ofstream, you have to do

(*out) << ...

Thanks for the reply that got it working :).
Topic archived. No new replies allowed.