我在創建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)
{
}
'無效的ReadFile(FLIST,mList)'你忘類型。 – chris
@chris:或者寧願忘記忽略返回類型。 – GManNickG
@GManNickG,哎呀,我什至沒有發現。我從函數頭複製了它。 – chris