Re: [ROOT] TFile *f global ?

From: Faine, Valeri (fine@bnl.gov)
Date: Wed May 29 2002 - 03:03:48 MEST


  
> Dear Rooters,
> 
> When I'm opening a file, I've got the following line of code:
> 
> void OpenFile()
> {
> ...
> TFile *f = new TFile("MyFile");
> ...
> }
> 
> 
> As far as I understand, f is available on the global scope if created
> this way.
> 
> In my GUI, I have a LineEdit which processes Root Command
> by gROOT->ProcessLine(RootCommand)... When I try: f->ls(),
> f is said to be out of scope. From the rest of my GUI, I can see that
> the object are still accessible...
> 
> something wrong ?
 
  Your understanding of the scope is wrong.

 To make *f global try:


 TFile *f = 0;
 void OpenFile()
 {
 ...
  f = new TFile("MyFile");
 ...
 }


   Hope this helps, Valeri



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET