Why is the name of the cloned canvas c1
in this simple example?
root [0] TCanvas* c1 = new TCanvas("c1", "c1")
(TCanvas *) 0x7fed10054770
root [1] c2 = c1->Clone("c2")
(TObject *) @0x7ffeea97ece8
root [3] c2->GetName()
(const char *) "c1"
Why is the name of the cloned canvas c1
in this simple example?
root [0] TCanvas* c1 = new TCanvas("c1", "c1")
(TCanvas *) 0x7fed10054770
root [1] c2 = c1->Clone("c2")
(TObject *) @0x7ffeea97ece8
root [3] c2->GetName()
(const char *) "c1"
I don’t know. Looking at it.
It is because TCanvas does not inherit from TNamed and the Clone() version used in that case is the one inherited from TObject which does not set the name.
Thank you. I thought that TCanvas
is derived from TNamed
because TCanvas::Clone
accepts a new name and TCanvas::SetName
exists.
Yes TCanvas::SetName exits but it is the one from TPad which holds its own name outside the TNamed class. Therefore Clone is the one from TObject which accept the name but does not set it. I agree it is a bit weird.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.