Re: TString question

Radovan Chytracek (Radovan.Chytracek@cern.ch)
Sun, 15 Mar 1998 17:06:22 +0100 (MET)


On Sun, 15 Mar 1998, Nick van Eijndhoven wrote:

> TString* s; // In the private area of Myclass
>
> // Next 2 lines are in the member function void Myclass::doit1()
> s = new TString("test");
> cout << " First test output " << s->Data() << endl;
This is OK, private member `s' is initialized already.

> // Next 2 lines are in the member function void Myclass::doit2()
> cout << " Here comes the second." << endl;
> cout << " Second test output " << s->Data() << endl;
In this case there is no guarantee that `s' is already initialized to
point to some memory area containg its data.

The method Myclass::doit2() can be used in the case when MyClass
constructor does the `s' initialization before the Myclass::doit2()
is called.

Happy ROOTing

Radovan