Dear Rooters
Meanwhile I could solve the problems, however I have still some questions:
ad 1 and 3: These questions are explained in the root guide, I am sorry.
ad 4 and 5: The problem with fDir is solved when I replace in lines 7 and
15
“vName = TString(vObj->GetName())” with “vName = vObj->GetName()”.
What is still not clear to me is why root breaks when I replace
"vObj->GetName()" with "vObj->GetString()"?
Thank you in advance.
Best regards
Christian
"cstrato@EUnet.at" wrote:
> Dear Rooters
>
> For my GUI I have the following main class:
>
> class TMyFrame {
> RQ_OBJECT()
>
> private:
> TGMainFrame *fMain;
> TGCompositeFrame *fFrame;
> TGMenuBar *fMenuBar;
> TGPopupMenu *fMenuFile;
> etc
> // Parameters
> TList *fList;
> TString fDir;
> etc
> public:
> TMyFrame(const TGWindow *vWindow, UInt_t vWidth, UInt_t vHeight);
> virtual TMyFrame();
> etc
> void FRun();
> };
>
> I have the following code fragment in the code FRun() for a menu item,
> which I can write in several ways:
>
> cout << "Directory: " << fDir << endl; //ok
> TString vName;
> TObjString *vObj; //or: TObjString *vObj = new TObjString();
> TIter next(fList); //or: TListIter next(fList);
> while (vObj = (TObjString*)next()) {
> //or: while (vObj = (TObjString*)next.Next()) {
> vName = TString(vObj->GetName());
> cout << "vName: " << vName << endl;
> }//while
>
> cout << "Directory: " << fDir << endl; //Error: No symbol fDir!!
>
> next.Reset();
> while (vObj = (TObjString*)next()) {
> vName = TString(vObj->GetName());
> cout << "Name: " << vName << endl;
> }//while
>
> 1, It is not quite clear to me why I can write "(TObjString*)next()"
> instead of "(TObjString*)next.Next()". Which way is better?
>
> 2, Is it enough to define "vObj" or ist it better to create it?
>
> 3, When should I use TListIter instead of TIter?
>
> 4, When I replace "vObj->GetName()" with "vObj->GetString()" in
> lines 7 and 15, the second while loop is no longer able to print
> the correct name. Why is this the case?
>
> 5, In the first line the directory fDir is printed correctly,
> however, in line 11 root prints the following error:
> "Error: No symbol fDir in current scope"
> However, this happens only when fList has more than one item!!
> Somehow, iterating fList using "while(..)" seems to scramble the
> memory.
> Can somone tell me what kind of mistake is in this part of the
> code?
>
> Thank you in advance.
>
> Best regards
> Christian
> ----------------------------------
> C.h.r.i.s.t.i.a.n S.t.r.a.t.o.w.a
> V.i.e.n.n.a, A.u.s.t.r.i.a
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:58 MET