Originally Posted by
laserlight
Once you have a user defined constructor for IssueQueue, the default constructor will no longer be automatically generated, thus you need to provide it yourself if it is necessary.
I don't want the default constructor called there, I want to say "Hey friendly compiler, I have an object named issue_queue that I will initialize in a few seconds but this is what it looks like". Though if this is really going to be this difficult then I'd rather have a default constructor and an issue_queue.initialize(x) function than passing issue_queue as an argument.
Originally Posted by
laserlight
That reasoning does not make sense to me. That you have objects of other classes that need to be initialised from command line arguments has no bearing on the decision to pass an object to an initialisation function.
Again, what I meant was that I have a few objects that would need to be passed around along with issue_queue, and not the same objects each time. This is what I mean:
Code:
void initialize(IssueQueue& issue_queue, ROB& rob, DispatchQueue& dispatch_queue, ExecutionList& execution_list, RegFile& reg_file)
{
int x;
... //* Give a value to x
issue_queue(x);
}
void dispatch(IssueQueue& issue_queue, DispatchQueue& dispatch_queue, ExecutionList& execution_list, RegFile& reg_file)
{
...
Instruction instr = new Instruction(...);
issue_queue.push(instr);
...
}
void execute(IssueQueue& issue_queue, ROB& rob, ExecutionList& execution_list, RegFile& reg_file)
...
issue_queue.pop();
...
}
Originally Posted by
laserlight
Then you should define another function that calls these functions, and then call that new function from main.
I think that your initialize function should take the IssueQueue by reference, or perhaps return an IssueQueue object by value (but this will rely on named return value optimisation to be efficient; yet you will not need a default constructor which may be a Good Thing).
I would still prefer an issue_queue.initialize() function to doing this do to the large inconsistent number of objects that need to be passed.
This seems like it should be a basic thing to me, but that could be because I am trying to kick the C habit. Here is what I'd like to have that works with a built-in type:
Code:
unsigned int depth;
void initialize()
{
int x;
...
depth = x;
}
void fetch()
{
int fetch_depth = depth;
...
}
I'm pretty sure that works in C++, and it's late but that should work in C, too.