void recdisp(struct node* p);
struct node{
int data;
struct node* link;
};
struct node* head;
int main()
{
recdisp(head);
return 0;
}
void recdisp(struct node* p)
{
if(p==NULL)
return;
recdisp(p->link);
printf("%d ",p->data);
}
在main之前声明了该功能!!!
最佳答案
解决方案
struct声明应该在函数声明之前。
如果首先声明功能会发生什么情况
因为没有声明结构,所以假定与该函数关联的参数是某些东西。
稍后在声明该结构并定义该函数之后,编译器现在使用该结构将其与该函数相关联,但是它早已与其他关联进行了此过程,因此需要重新声明
关于c++ - 错误: ‘recdisp’的类型冲突void recdisp(struct node * p),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62548414/