使用 boost graph 创建结构体
我想使用我用图形创建的结构:
typedef struct type_INFOGRAPH
{
boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS, Node, Line > graphNetworkType;
map<int,graph_traits<graphNetworkType>::edge_descriptor> emymap;
map<int, graph_traits<graphNetworkType>::vertex_descriptor> vmymap;
}INFOGRAPH;
但是当我尝试用函数构造图形时:
INFOGRAPH *infograph = NULL;
infograph->graph = CreateGraphFromDataset3(file);
我收到如下错误:
"Unhandled exception at 0x00ae4b14 graph.exe : 0xC0000005: Access violation reading location 0x00000018."
I whant to use this structure that I've created with a graph:
typedef struct type_INFOGRAPH
{
boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS, Node, Line > graphNetworkType;
map<int,graph_traits<graphNetworkType>::edge_descriptor> emymap;
map<int, graph_traits<graphNetworkType>::vertex_descriptor> vmymap;
}INFOGRAPH;
But when I trie to construct the graph with a function:
INFOGRAPH *infograph = NULL;
infograph->graph = CreateGraphFromDataset3(file);
I get an erro like this:
"Unhandled exception at 0x00ae4b14 graph.exe : 0xC0000005: Access violation reading location 0x00000018."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑这是否可以编译,因为您的 INFOGRAPH 类甚至没有名为 graph 的成员。
但更重要的是,您从未创建过该类的实例 - 您只是创建了一个指针,将其设置为 NULL 并取消引用它。当然,这是无效的并且会让你崩溃。
您可以自动或动态创建实例,具体取决于您将如何使用它:
I doubt this even compiles, since your
INFOGRAPH
class doesn't even have a member calledgraph
.More importantly, though, you've never created an instance of the class - you just made a pointer, set that to NULL and dereferenced it. Naturally that isn't valid and gets you crashed.
You can make an instance either automatically or dynamically, depending on how you're going to use it: