Hi Tom,
Use:
class Zap {
public:
TList &list();
};
TList &Zap::list() {
static TList list;
return list;
}
which anyway is slightly better in term of C++ style :)
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On
Behalf Of Tom Roberts
Sent: Monday, May 26, 2008 1:12 PM
To: 'ROOT Talk'
Subject: [ROOT] Question about static class objects
I am puzzled why this fails (Root 5.16 or 5.18, on Fedora Core 8).
file zap.C contains: class Zap { public: static TList list; }; TList Zap::list;
$ root -l
root [0] .L zap.C root [1] Zap::list.Clear(); *** Break *** segmentation violation [....] But this works:
$ root -l
root [0] TList zap; root [1] zap.Clear(); root [2] .q
Any suggestions how to work around this?
Tom Roberts Received on Tue May 27 2008 - 19:02:32 CEST
This archive was generated by hypermail 2.2.0 : Tue May 27 2008 - 23:50:01 CEST