结构体错误不明白

来源:百度知道 编辑:UC知道 时间:2024/05/31 23:27:22
--------------------Configuration: 宿管系统 - Win32 Debug--------------------
Compiling...
main.cpp
c:\program files\microsoft visual studio\myprojects\宿管系统\head.h(5) : error C2011: 'Student' : 'struct' type redefinition
c:\program files\microsoft visual studio\myprojects\宿管系统\head.h(5) : error C2011: 'Student' : 'struct' type redefinition
Error executing cl.exe.
结构体如下:
//head.h
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
struct Student
{
int number;
char name[10];
char sex[4];
int dor;
int age;
struct Student *next;
};
我自己解决了
不好意思了。

#pragma once//加上这个看看
struct Student
{
int number;
char name[10];
char sex[4];
int dor;
int age;
Student *next; //去掉struct
};

结构体没有错误。是说你在其他地方重复定义了结构体。
因为你没发全。。所以不知道你是在哪儿重复定义了。。。

#ifndef HEAD_H__
#define HEAD_H__

#inlcude <stdio.h>
....
....

#endif