Reputation: 79
I think there's something basic I'm missing here but I have a vector of a structure I made called 'Event' called eventTable that I'm trying to access from within a function. I'm getting this error: "Invalid arguments ' Candidates are: void push_back(const Event &)" Any suggestions?
struct Event {
enum TYPE {
Arrival,
CPUBurstCompletion,
IOCompletion,
TimerExpired
};
double time;
TYPE type;
Event(Event::TYPE type, double time)
: type(type),
time(time) {}
};
vector<Event> eventTable;
void createEvent(Event::TYPE type, double time){
Event newEvent(Event::TYPE type, double time);
eventTable.push_back(newEvent);
}
Upvotes: 0
Views: 129
Reputation: 63471
Do not include the types. You want to construct an object, not declare a function. This constructs an object:
Event newEvent(type, time);
Upvotes: 2
Reputation: 23624
Event newEvent(Event::TYPE type, double time);
This is not to create an object of Event
class. The vector eventTable
stores objects of Event
, however, you are not providing objects of Event
in your current way. You were declaring a function.
Try:
Event newEvent(type, time);
Upvotes: 1