typedef 使用
比如, typedef G4THitsCollection<B2TrackerHit> B2TrackerHitsCollection; 将 G4THitsCollection<B2TrackerHit> 重命名为 B2TrackerHitsCollection
文件流作为函数参数
1 void fitshape(std::ofstream &ffo, TString fitfunc, Int_t start, Int_t stop); 2 3 std::ofstream ffo; 4 ffo.open("test.tt", std::fstream::app);
5 TString sss("test"); 6 fd_tmp->fitshape(ffo, sss, 0, 4000);
注释 ifdef endif
1 #ifdef DRAW 2 TApplication the_app("app", &argc, argv); 3 #endif
strstr() 函数,实现字符串的截断
1 /* strstr example */ 2 #include <stdio.h> 3 #include <string.h> 4 5 int main () 6 { 7 char str[] ="This is a simple string"; 8 char * pch; 9 pch = strstr (str,"simple"); 10 puts (str); 11 return 0; 12 }
文件读取示例
1 // read file and add to fit object 2 Double_t *x = new Double_t[133]; 3 Double_t *y = new Double_t[133]; 4 Double_t vX, vY; 5 Int_t vNData = 0; 6 ifstream vInput; 7 vInput.open(Form("%smotorcycle.dat",dir.Data())); 8 while (1) { 9 vInput >> vX >> vY; 10 if (!vInput.good()) break; 11 x[vNData] = vX; 12 y[vNData] = vY; 13 vNData++; }//while 14 vInput.close(); 15 16 delete [] x; 17 delete [] y;