| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
如题,在定义结构体时遇到了一些问题,错误提示时error: 'void init(<anonymous struct>*)', declared using anonymous type, is used but never defined [-fpermissive]|
- #include <iostream>
 
  
- typedef struct data
 
 - {
 
 -         int id;
 
 -         char *name;
 
 - }Data;
 
  
- typedef struct staticlinkedlist
 
 - {
 
 -         Data dt;
 
 -         int Cnext;
 
 - }StaticLinkedList[10];
 
  
- void init(StaticLinkedList tar)
 
 - {
 
 -         for(int i = 0; i < 0; i++)
 
 -                 tar[i].Cnext = i+1;
 
 -         tar[8].Cnext = 0;
 
 -         tar[9].Cnext = 0;
 
 - }
 
  
- void Show(StaticLinkedList tar)
 
 - {
 
 -         for(int i = 0; i < 10; i++)
 
 -                 std::cout << tar[i].Cnext << std::endl;
 
 - }
 
  
- int main()
 
 - {
 
 -         StaticLinkedList s1;
 
 -         init(s1);
 
 -         return 0;
 
 - }
 
  复制代码都说了没有结构体名~~~ 然后 struct xxx -> typedef struct xxx  XXX 不要用相同的名字  
 
 
 |   
- 
定义结构体时直接声明为数组形式 
 
 
 
- 
作为参数传给函数的时候就传不进去 
 
 
 
- 
函数顶底 
 
 
 
 
 
 
 
 |