I have a class called IssueQueue. I have a function called initialize() which will read arguments from the command line and initialize an IssueQueue object according to the arguments. I have other functions which then need to use the IssueQueue object that was initialized in initialize().
I've tried declaring an IssueQueue outside of all functions to make it global but I received an error about no constructor with zero arguments. In my examples in my first post, IssueQueue would be Foo and initialize would be bar, just to show what I have tried so far.
Passing issue_queue around as an argument seems like a poor design because there are a few classes similar to IssueQueue that I need to do this with. As another reason not to pass it as an argument, all of these functions that use IssueQueue will be called by main and I have no reason to make the IssueQueue object visible to main. All of these functions (except main) will be contained in the same file, though.
dynamic_scheduler.cpp
Code:
IssueQueue issue_queue; //* Error here
void initialize()
{
int x;
... //* Give a value to x
issue_queue(x);
}
void dispatch()
{
...
Instruction instr = new Instruction(...);
issue_queue.push(instr);
...
}
void execute()
{
...
issue_queue.pop();
...
}