TFile Question

So,

 I need to open a few different root files and instead of instantiating several different TFile objects I just wanted to have a pointer to one and then open the files one at a time.  So I did the following...
TFile *file = new TFile();

file->Open("firstfile.root");

// Do processing

file->Close();

file->Open("secondfile.root");

// Do Processing

file->Close();

Now this failed to work, it was as if the files were not open. So then I did some looking and found the the return type for TFile::Open was TFile* and not bool. So, it worked when I did the following:

TFile *file = new TFile();

file = file->Open("firstfile.root");

Problem here is that a memory leak has just been introduced. Am I doing something really wrong or is this the intended way for this class to work?

Justace

Do:

[code]TFile *file = TFile::Open(“firstfile.root”);

// Do processing

delete file;

file = TFile::Open(“secondfile.root”);

// Do Processing

delete file;
[/code]
Rene

Does this still present the memory leak. When the open command runs does it allocate a new section of memory to store the object? What is the null constructor designed to do?