I am trying to create a program that is an event simulation using the STL priority queue. I created the operator < function inside a struct, but when I run the program I get an error that I do not know how to make sense of. I have had a link error in the past (different project), but I was using different files and I was able to get rid of it by creating a new project with one file and then splitting up the client, implementation, and header file. However, this project is all in one file.
ERROR:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "struct Event __cdecl processArrival(struct Event,class std::priority_queue<struct Event,class std::vector<struct Event,class std::allocator<struct Event> >,struct std::less<struct Event> >,class std::queue<struct Event,class std::deque<struct Event,class std::allocator<struct Event> > >)" (?processArrival@@YA?AUEvent@@U1@V?$priority_queue@UEvent@@V?$vector@UEvent@@V?$allocator@UEvent@@@std@@@std@@U?$less@UEvent@@@3@@std@@V?$queue@UEvent@@V?$deque@UEvent@@V?$allocator@UEvent@@@std@@@std@@@3@@Z) referenced in function "void __cdecl simulate(void)" (?simulate@@YAXXZ)
If I comment out the operator < function I'll get this error, which I think is because the priority queue by nature needs to have operator < implemented:
Severity Code Description Project File Line Suppression State
Error C2676 binary '<': 'const _Ty' does not define this operator or a conversion to a type acceptable to the predefined operator wk_11_sortedList_queues C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\xstddef 127
I posting just this because that is where the problem is, but if I need to post something else please let me know.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
struct Event
{
int customerID;
int transactionTime;
int arrivalTime;
int currentTime;
bool operator < (const Event& right) const
{
return this->arrivalTime < right.arrivalTime;
}
};
|