If you just want the syntax of a non-pointer object, use a reference:
TTree& tree = *static_cast<TTree*>(file.Get("treename"));
(Note that I replaced the C-style cast with a static_cast
, which is not necessary, but usually considered good style.)
Note, however, that if you had to delete the TTree*
, declaring it as a TTree&
will not free you from this duty.