这一切都在头文件中,主要是它非常简单,我声明一个列表然后填充它,没有问题,并且可以从头文件中的另一个函数打印列表没有问题,但问题来了带有排序功能。它一直说它
严重性代码描述项目文件行抑制状态错误 C2664 'bool (Bike *,Bike *)':
无法将参数 2 从 '_Value_type' 转换为 'Bike *' Project7 C:\Program Files (x86)\Microsoft Visual Studio\2019\社区\VC\Tools\MSVC\14.24.28314\include\xutility 1481
//the argument for the sort function
bool comp_id(Bike* b1, Bike* b2)
{
return b1->id_num < b2->id_num;
}
//This is how I plan on sorting it.
// Also, side note can I do list<Bike> secondList = head; and then sort secondList.sort(comp_id)?
head.sort(comp_id);
for (auto iterator = head.begin(); iterator != head.end(); ++iterator)
{
cout << iterator->id_num << endl;
}
//This is the Structure
struct Bike
{
char manufact[25];
int id_num;
status rented_code; //RENTED/NOT_RENTED
char to_whom[25]; //to whom bike is rented
int size;
float cost_per_day;
bool deleted; //to mark bike as deleted in the list.
Bike* next_manuf; //pointer to next node in the
//manufacturers list
Bike* next_id; //pointer to the next node
//in the list by ID
Bike* next; //pointer to the next node in the general list
};