我在用 C++ 制作结构数组时遇到了麻烦。由于某种原因,这不会编译。错误指向 Fem 结构,但将其归咎于缺少 ';' 并且缺少函数的标题。这个想法是获得一个结构数组,其中每个结构都有一个数组和一个字符串。对此的任何帮助将不胜感激。
/* Global headers and namespace */
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdlib>
#include <cctype>
using namespace std;
/* ================================================================ */
/* Global named constants */
const int NUM_ANSWERS = 10;
const int NUM_STRUCTS = 15;
/* ================================================================ */
/* Global type definitions */
// Two struct types, Male and Female
struct Male
{
int maleAnswers [NUM_ANSWERS];
string name;
};
struct Fem
{
int femAnswers [NUM_ANSWERS];
string name;
};
// Arrays of structs
typedef Fem FemList [NUM_STRUCTS];
typedef Male MaleList [NUM_STRUCTS];
/* ================================================================ */
/* global function prototypes */
void OutputHeader ();
void ReadFile (FemList, MaleList);
/* ================================================================ */
int main ()
{
FemList fList; // Array of Fem structs
MaleList mList; // Array of Male structs
void OutputHeader ();
void ReadFile (fList, mList);
}
void OutputHeader ()
{
cout << "==================================================================" << endl;
cout << "Welcome to the Cheap & Ineffective Dating Service of Tallahassee!" << endl << endl;
cout << " eDisHarmony.com" << endl;
cout << "==================================================================" << endl << endl;
cout << "<><><> Initial Client Data as Input <><><>" << endl << endl;
cout << setw(11) << "Sex" << setw(31) << "Answers" << "Name" << endl;
cout << setw(11) << "---" << setw(24) << "-------------------" << "--------------------" << endl;
}
void ReadFile (fList, mList)
{
}