Answer the question
In order to leave comments, you need to log in
How to initialize a static field?
Good afternoon.
There is a class agents, it has a static field
static graph general_graph;
Where graph is another class. This class has a fill() method - it reads a graph from a file.
Problem: I can't initialize a static variable with a graph object with the fill() method already executed without creating a global object.
outside the main function I write the following code:
graph agents::general_graph = *(new graph());
the code compiles without error, but how do you call the fill() method on initialization?
Answer the question
In order to leave comments, you need to log in
This class has a fill() method - it reads a graph from a file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question