The unix command “cd” works for the current shell only. You have the same effect if you run the “cd” command inside a script shell. For instance, try to create a little file in which you change directory using “cd” , execute it the as a shell script (with the “sh” command), then type “pwd”. You will see that the directory has not changed. It was changed only during the script execution. That’s the same in ROOT.
TH1F *h1 = new TH1F(“h1”, “Histogram”, 100, -4, 4) creates a pointer to a TH1F object. You acess the the methods using “->”
TH1F h1(“h1”, “Histogram”, 100, -4, 4) creates an object TH1F (not a pointer). You access the methods using “.” . This in valid C++, this is not CINT shortcut.
You’d better read some C++ book to understand difference between first and second statements. Very primitive explanation is :
In the first statement you declare and initialize a pointer, its initializer is a new-expression.
This new-expression works in several steps : operator new called (in our case it’s an overloaded operator new) - to allocate dynamic memory for object of type TH1F. After that, constructor for TH1F called with your parameters to initialize new object, address of this new object will be initial value for your pointer.
In second - you declare (and define an object). Implementation allocates memory for it (on stack or somewhere else for object with static storage duration) and call ctor.