Re: TString question

Radovan Chytracek (Radovan.Chytracek@cern.ch)
Sun, 15 Mar 1998 16:15:26 +0100 (MET)


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

>
> TString* s; // In the private area of my class
>
> s = new TString("small_test"); // In one of the initialisation
> // member functions
>
> char* ch=s->Data(); // In another member function.
>
> However, the last statement gives me an error message in ROOT
>
> "illegal pointer to class object".
>
> I also tried : char* ch=(char*)s->Data();
> char* ch=(const char*)s->Data();
>
> but nothing worked.

May be the following scenario will work:

class MyClass {

private:

TString *s;
...

public:

char *GetData()
{
return( s->Data() );
{
...
};

Use it as:

MyClass mcls;

char *ch = mcls.GetData();

Happy ROOTing

Radovan