Another neophyte question

What does an asterisk after a class name mean? (see the two lines of code)

TFile trigfile = new TFile(“trigger.root”,“recreate”);
TTree
trig = new TTree(“trig”,“trig”);

thanks,
harry

Harry,

I suggest to read some C++ tutorials. For example
www-pnp.physics.ox.ac.uk/~west/w … s/cpp.html
cplusplus.com/doc/tutorial/
cplusplus.com/doc/tutorial/tut3-3.html

Rene

i read such things very carefully and they don’t have an asterisk AFTER a class name, I suspect that it is a ROOT nomenclature but it is not explained in the manual, I do know what a pointer is.

This has nothing todo with the ROOT nomanclature. It is just the way
a C++ pointer is declared.

Rene

Hello.

VERY CAREFULLY ???
Link number 3 from Rene’s list contains:

Section 3.3
Pointers

cplusplus.com/doc/tutorial/tut3-3.html
and for example:

cplusplus.com/doc/tutorial/tut4-1.html

rene, we shouldn’t be upset with each other, look at the lines i copied carefully. it has “TTree*” with no space after TTree, this is new to me, I was worried that it was something special to root, the examples you have quoted do not have such an instance, i have looked very carefully at various resources and have not seen a “*” right after a class name without a space. Maybe my fault is to scrutinize too carefully, I want to make sure that I use Root properly as I think it’s very nice of all of you to create it. I used PAW extensively and was one of the first ntuple users in my group at bnl physics. I have been away from the field and am bootstrapping myself so little trivialities trip me up.

harry

sorry, tpochep quoted code, not Rene. and thank you, rene, simply telling me that it is a C++ artifact and not ROOT is a helpful answer.
harry

Harry,

There are two styles to declare pointers

Myclass* obj; Myclass *obj;

Most of the time in C++ code, you find the first style.
In ROOT code, you mostsly find the second style. The reason is that we see many mistakes of the type

where the user in fact was intending to declare

Rene

now I understand the problem, believe it or not, all of the code I’ve seen has the second style,

Myclass *obj;

If you are accustomed to the first style (which I agree is better) then my question appears as if I did no homework, which I always do so as to not waste any one’s time. I only ask when I can’t find something.

thsnk you
harry

Hello, Harry.

Yesterday, after I quoted this text and before your answer I realized your problem :blush: From compiler’s POV there are tokens:

class_name
*
ptr_name

new
class_name
(
etc…

So it does not matter, there is *. You can declare

Type ptr
Type
ptr
even
Type*ptr