私はキューリンクリストキュー[ポップ機能]
/**
* This function extracts from the queue the patient with maximum priority
* @param queue is the extraction point
* @return the patient with maximum priority or a Patient type value with all the fields 0 if the queue is empty
*/
struct Patient priorityQueuePop(struct PriorityQueue *queue);
構造体の優先度つきキューから要素をポップ機能を作成しようとしているがこれです:
struct PriorityQueue{
unsigned size;
struct PriorityQueue *next;
struct PriorityQueue *front;
struct PriorityQueue *rear;
}
、患者はこれです:
:enum Gender {
MALE = 'M',
FEMALE = 'F'
};
struct Patient {
char firstName[20];
char lastName[20];
unsigned char age;
enum Gender gender;
};
私はこのようなものを作ってみました
struct Patient priorityQueuePop(struct PriorityQueue *queue){
struct Patient *item =(struct Patient*)malloc(sizeof(struct Patient));
queue->front = queue->front->next;
queue->size--;
return item;
}
が、私はそれをコンパイルするとき、私はエラーを取得:
priorityQueue.c:72:2: error: incompatible types when returning type ‘struct Patient *’ but ‘struct Patient’ was expected
return item;
誰かがこれを行うべきであるか嘆願を説明できますか? ありがとうございました
質問はどこですか? – Boiethios
構造が正しくないようです。 'PriorityQueue'構造体には、すべてのノードの頭や尾へのポインタが含まれており、' PriorityQueue'構造体と 'Patient'構造体の間には関係がありません。 – interjay
エラーメッセージは自己説明可能です: 'priorityQueuePop'関数は' struct Patient'を返すと宣言しますが、 'struct Patient *'型の 'item'を返しています。 – ericbn