#include #include "TFile.h" #include "TTree.h" void tree_str_test_3 () { TFile *f = new TFile("tree_str_test_3.root","recreate"); TTree *t = new TTree("t","tree t"); std::string str_1, str_2; t->Branch("str_1",&str_1); t->Branch("str_2",&str_2); str_1 = "aa1"; str_2 = "aa2"; t->Fill(); str_1 = "bb1"; str_2 = "bb2"; t->Fill(); str_1 = "aa1"; str_2 = "bb2"; t->Fill(); f->Write(); }