Christian Doerr wrote: > > Hello everybody, > > I just started using root - and I'm also new to this mailing list - so > maybe the solution to my problem is trivial. > > I want to create a class object (class TMyList) in a > first macro named TEvent.C as global variable gList and then use/read > it again from a second macro: > > root[1] .L TEvent.C > root[2] InitList(); > root[3] .g > > .... > TEvent.C 294 0x868e360 TMyList gList , size=8 > .... > > root[4] > > How can I access gList again from another macro? Here it follows: ------------------------------ cut here InitGlobal.cpp ------------------------------- #include <iostream> class A { public: A(){} ~A(){} void Show() { std::cout << "This is object of class A" << std::endl; } }; A gAobject; void InitGlobal() { std::cout << "Global object of A initialized..." << std::endl; } ------------------------------ cut here InitGlobal.cpp ------------------------------- ------------------------------ cut here UseGlobal.cpp ------------------------------- extern A gAobject; void UseGlobal() { std::cout << "Trying to use the global object of class A" << std::endl; gAobject.Show(); } ------------------------------ cut here UseGlobal.cpp ------------------------------- In ROOT type: .x InitGlobal.cpp .x UseGlobal.cpp you should get: root [0] .x InitGlobal.cpp Global object of A initialized... root [1] .x UseGlobal.cpp Trying to use the global object of class A This is object of class A Hope this helps Radovan
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:45 MET