(C++) 如何将 stl 列表声明为 extern?

发布于 2024-09-27 01:30:51 字数 221 浏览 0 评论 0原文

我有:

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

在我的 main.cpp 中。我需要在我的一个类文件中将这两个声明为 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2024-10-04 01:30:51
extern std::list<Particle> particles;

如果这不起作用,那么您还有其他错误。您是否包含了 并且 Particle 的定义在声明 articles 时可见?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文