tags:

views:

51

answers:

1

I have:

std::list<Particle> particles;
std::list<Particle>::iterator particleit;

in my main.cpp. I need to declare both of these as extern in one of my class files, but my compiler gives me some error about a missing '>' when I try the straightforward way. How would I go about fixing this?

+1  A: 
extern std::list<Particle> particles;

If that doesn't work, then you have some other error. Have you included <list> and is the definition of Particle visible where particles is declared?

James McNellis
Thanks. It compiles now. But I have another issue with the application freezing, now. I'll probably have that solved, though. Thanks again.
Alex Grabanski
That can incur the initialization order fiasco… best practice is a `static` function local.
Potatoswatter
Right, the 'freeze' might come from an attempt to access the global object before it was initialized. Best practice is to avoid non-local objects at all, but if yon feel you must do it that way rather use a well designed singelton holder...
paul_71