Hello, I have the following code
[code]#include <TTree.h>
#include
using namespace std;
void init_tree(TTree* t) {
t = new TTree(“t”,“t”);
if(t) cout << “t exists” << endl;
}
void test() {
TTree *t = NULL;
if(!t) cout << “t does not exist” << endl;
init_tree(t);
if(!t) cout << “t still does not exist” << endl;
}[/code]
When I run it, I got the following output
[quote]t does not exist
t exists
t still does not exist[/quote]
I think it is really a basic question but I do not understand why the operation on the pointer “t” is not “saved” after the step in the function “init_tree”.
How should I write my code in order to construct my TTree within a function and to keep it “constructed” after I quit the function?
Thank you in advance