问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
//定义顺序队列
typedef struct{
int data[Maxsize];
int front;
int rear;
} SqQueue;
//初始化队列
void initQueue(SqQueue *qu){
qu->front = qu->rear = 0;
}
//入队
int enQueue(SqQueue &qu, int x){
if((qu.rear+1)%Maxsize==qu.front){
return 0;
}
qu.data[qu.rear] = x;
qu.rear = (qu.rear+1)%Maxsize;
return 1;
}
int main(){
SqQueue qu;
initQueue(&qu);
int status = enQueue(&qu, 1);
return 1;
}
运行结果及报错内容
[Error] invalid initialization of non-const reference of type 'SqQueue&' from an rvalue of type 'SqQueue*'
[Note] in passing argument 1 of 'int enQueue(SqQueue&, int)'