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."
I doubt this even compiles, since your INFOGRAPH
class doesn't even have a member called graph
.
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:
// Automatic:
INFOGRAPH infograph;
infograph.graph = CreateGraphFromDataset3(file);
// Dynamic:
INFOGRAPH * pinfograph = new INFOGRAPH;
pinfograph->graph = CreateGraphFromDataset3(file);
// ouch, who cleans up `*pinfograph` now?
User contributions licensed under CC BY-SA 3.0