【发布时间】:2021-12-26 05:34:07
【问题描述】:
我正在编写一个程序,它以表格的形式显示一些学生的考试成绩,然后计算并显示平均值。运行代码后,我收到以下错误(也如下图所示): 变量的类型不完整 “组织学生” 结构学生 st[50]; ^ 注意:“学生”的前向声明 struct students st[50];
我已经声明了学生并尝试声明 st,但我不确定问题是什么。以下是我的代码的打字版本和屏幕截图:
#include <iostream>
using namespace std;
int Main()
{
int students;
struct students st[50];
return 0;
}
【问题讨论】:
-
您将
students声明为int,您没有定义一个名为students的struct,因此struct students没有引用已定义的类型,因此出现错误。跨度> -
旁注:
using namespace std;是一种反模式。请不要那样做。
标签: c++ struct compiler-errors declaration incomplete-type