Hi,
TROOT::GetSelectedPad() returns pointer at TVirtualPad, so replace this line
by
TPad current_pad = (TVirtualPad)gROOT->GetSelectedPad(); [color=red]<- this is a mistake (see tpochep’s post below)[/color]
or simply use
TPad *current_pad = gPad;
My message about ill-formed code was not addressed to you.
kbat wrote ill-formed code
TPad * p = gROOT->GetSelectedPad();// here is an error - even if CINT can interpret it, in C++ you cannot assign
Base * p = new Derived;//standard implicit conversion
Derived * p1 = p; //this is inverse of standard conversion, it requires EXPLICIT cast (you can use static_cast, C-style cast, functional-style cast (with correspondent typedef), even dynamic_cast ).
It’s a CINT bug, that you can assign TVirtualPad * to TPad *
You get 0 (it’s only IMHO) from GetSelectedPad because after pad creation you have not selected it. But gPad contains correct pointer you need. After all you first code is very strange, what are you going to do with it?