I can't use TLine and compile my code

with the following lines I would like to draw some simple lines on a plot.

TCanvas *cTest = new TCanvas();
double t1, t2;
TLine *line = new TLine(0.3,t1,0.3,t2);

when I try to compile my code, i get the following error (test is my script):

test_v2_1.C:937: error: expected constructor, destructor, or type conversion before ‘->’ token
make: *** [test_v2_1.o] Error 1

I’ve included the libary TLine.h ( #include “TLine.h”).
If I run a script with the above lines, everything is fine. Do you have any suggestions which may help me solve this issue?

Thank you in advance.

P.S. I’m using root v.5.18/00d


Which of the four lines you quote is line number 937?
Did you try to compile a script/function with just those lines (i.e. is something else interfering which the lines of code you quotes)?



I solved the problem after using TLine *line … before the void function and the line->Draw(), inside the void. No errors, but I don’t see an effect on my canvas…

What I want to do is to fill a canvas with some data and draw some regions on the same canvas using TLine (or maybe graph??)

Thanks in advance,

Post the shortest possible RUNNINg version of your script


I manage to see the drawings after creating my canvas inside the void func. What is strange to me is, why I cannot use TLine *line … inside the void func and compile (without errors :slight_smile: )…

Apart from this, I couldn’t manage to draw a graph and a histo in the same Canvas-but for now I can leave with this…

Thanks for your help,

It is impossible to understand what you are talking about without having an example. Please see my previous mail.