Can't use (TString*) mystring(i) in class

In a script, I can say

TString *s = new TString(“hello”);
cout << s(3) << endl;

since these lines are in TString.h:

char& operator()(Ssiz_t i);
char operator()(Ssiz_t i) const;

but in a class that I’m writing, it gives me an error!

TString *formatstring = new TString();
ifstream fInfile;;

g++ -O3 -Wall -fPIC -Wno-deprecated -D_REENTRANT -I/usr/local/root/include -c -o TEXOAsciiTree.o In method void TEXOAsciiTree::ParseFormatLine ()':’ cannot be used as a function warning: `char *buf’ might be used uninitialized
in this function
gmake: *** [TEXOAsciiTree.o] Error 1

instead, I have to strcpy into a buffer, but I’d rather do it with just TString. I know the string is getting read out correctly, since

cout << formatstring->Data() << endl;

gives the right output.


Jesse Wodin


In your case you have a pointer instead of an object. Hence you have to use something like

PS Note that the following would also work