简体   繁体   中英

(C++) How to declare a stl list as extern?

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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM