Hi Thomas,
Yes the object will still be valid __unless__ it is an histogram, tree or event list. Those 3 types of objects are by default owner by the file they are read from.
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
On Behalf Of Thomas Bretz
Sent: Monday, April 18, 2005 10:12 AM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] TDirectory::Get...
Hi,
there is something which is not clear to me, maybe you can help: If I get an object using TDirectory::Get, is this object still valid when the file is closed?
Would the following work?
TObject *ReadObject(const char *filename, const char *objname)
{
TFile f(filename, "READ");
return f.Get(objname);
}
void main()
{
TObject *o = ReadObject("myfile.root", "MyObject");
// Do something with it
delete o;
}
Thanks,
Thomas.
Received on Mon Apr 18 2005 - 20:47:23 MEST
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:07 MET