Re-using a pointer to a TBox

Hello,

This code:

[code]{
c1 = new TCanvas(“c1”,“Matrixes”,20,10,800,600);
c1->SetBorderSize(0);
c1->Range(0,0,133,100);
Double_t width = 35;
Double_t height = 26;

Double_t lx = 10;
Double_t ly = 10;

TBox* box1 = new TBox(lx,ly,lx+width,lx+height);
box1.SetFillStyle(0);
box1.SetLineStyle(1);
box1.Draw();

Double_t lx = 50;
Double_t ly = 10;

box1 = new TBox(lx,ly,lx+width,lx+height);
box1.SetFillStyle(0);
box1.SetLineStyle(1);
box1.Draw();

}[/code]

causes this CINT error:

Error: box1 already declared as different type matrixes.C:11:

I use that idiom all the time for TLatex objects: why does it not work for a TBox?

Thanks,
Roger

With the code you provided and ROOT 5.34/18 I can not reproduce this problem - macro is executed successfully.

Side Note:

To write correct C/C++ you should do:

box1->SetFillStyle(0);

instead of :

box1.SetFillStyle(0);

ROOT accept both, but if you want to compile your code later you will have to change it.

And to day it is working as expected for me. I don’t know what was going on yesterday. Unfortunately, there are some things that don’t work ([url]Root crashes on FreeBSD 10

ROOT 5.34/18 (v5-34-18@v5-34-18, Mar 14 2014, 16:29:50 on freebsd7)

Cheers,
Roger