Hello,
This could be a novice c++ question (as I seem to forgot
basic C grammar).
PLease see “tree2.C” example in the tutorial
root.cern.ch/cgi-bin/print_hit_b … ee2.C.html
I see someone define an array variable like this way
…
t2.Branch(“vect”, &gstep.vect,“vect[7]/F”);
instead of
…
t2.Branch(“vect”,gstep.vect,“vect[7]/F”);
as shown in the tree2.C tutorial.
I think it should be w/o “&” as an array name itself is
already a pointer to the array, but somehow "&array_name"
also seems to work. Can anyone explain why this works?
and which one is correct way?
My question can be simply why “array_name”,
"&array_name[0]", and “&array_name” give the
same pointer? e.g.
{
#include
int a[10];
printf("%p, %p, %p\n", a, &a[0], &a);
}
I thought that “a” and “&a[0]” are correct but “&a” is not.
But “&a” seems to be also a correct in C/C++?
Regards,
Chul Su