使用“extern”类内部给了我“指定的存储类”错误
我正在尝试在全球范围内使用“Graph”变量。
我在没有“extern”的情况下在课堂上定义它没有问题, 但是当我添加“extern”时,它会出现以下错误。 错误和正确的使用方法是什么? 谢谢。
我收到的错误消息:
error: storage class specified for ‘g2_’
extern Graph g2_;
^~~
头文件:
namespace ompl
{
namespace geometric
{
class AAA: public PRM
{
public:
typedef boost::adjacency_list <
boost::vecS, boost::vecS, boost::undirectedS,
boost::property < vertex_state_t, base::State*,
boost::property < vertex_total_connection_attempts_t, unsigned long int,
boost::property < vertex_successful_connection_attempts_t, unsigned long int,
boost::property < boost::vertex_predecessor_t, unsigned long int,
boost::property < boost::vertex_rank_t, unsigned long int > > > > >,
boost::property < boost::edge_weight_t, base::Cost >
> Graph;
extern Graph g2_;
};
}
}
#endif
I'm trying to use "Graph" variable globally.
I have no problem defining it in class without 'extern',
but when I add 'extern', it gives following error.
What's wrong and right way to use it?
Thank you.
Error message I got :
error: storage class specified for ‘g2_’
extern Graph g2_;
^~~
Header File :
namespace ompl
{
namespace geometric
{
class AAA: public PRM
{
public:
typedef boost::adjacency_list <
boost::vecS, boost::vecS, boost::undirectedS,
boost::property < vertex_state_t, base::State*,
boost::property < vertex_total_connection_attempts_t, unsigned long int,
boost::property < vertex_successful_connection_attempts_t, unsigned long int,
boost::property < boost::vertex_predecessor_t, unsigned long int,
boost::property < boost::vertex_rank_t, unsigned long int > > > > >,
boost::property < boost::edge_weight_t, base::Cost >
> Graph;
extern Graph g2_;
};
}
}
#endif
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论