ClassName vs Class_Name

I am puzzled by the behaviour of ClassName() vs Class_Name() and Class()->GetName().
The following code:

root [0] TH1F *h1 = new TH1F ();
root [1] TH1* h2 = (TH1*) h1->Clone("h2");
root [2]  h2->ClassName()
(const char *) "TH1F"
root [3] h2->Class_Name()
(const char *) "TH1"
root [4] h2->Class()->GetName()
(const char *) "TH1"

according to the reference guide both ClassName and Class_Name should return the name of the class of the object, so why are they different?

ROOT Version: 6.12/04 (but tried also ROOT 5)
Platform: Linux Ubuntu 18
Compiler: tried both interpreter and g++

One is a virtual function (ClassName) and the other is a static function (Class_Name).
So ClassName tells you about the object actual type while Class_Name tells you about the pointer type.

Similarly Class is a static function and the corresponding virtual functon is IsA.

In first approximation you probably want to use “just” ClassName and IsA.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.