未定义的数组访问问题 [英] undefined array access problem

查看:87
本文介绍了未定义的数组访问问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我需要你的帮助来解决这个问题。我有programme.not正确编译。它已经成为错误错误是我有大胆的错误地方





未定义引用'addStudent(student *,int&)'



hi all,

i need your help to solve this problem.i have programme.not compiling properly. it has become error the error is i have bold the error place


undefined reference to 'addStudent(student*, int&)'

#include <iostream>
#include <iomanip>
#include <math.h>
#include <stdlib.h> //for system("cls")
#include <process.h>  //for exit()
#include <conio.h>

using namespace std;

const int MAX_NO_OF_STUDENTS = 100;

struct student
{
    char indexNo[10];
    double marks[1][3];
    char grade;
    double zScore;
};

double result[7][3];


/*************************************************************
*             Function prototype declarations                *
*                                                            *
**************************************************************/

int mainMenu();          //Prints the main menu
void reportSubMenu();    //Prints the report sub menu
void graphSubMenu();     //Prints the graph sub menu

int addStudent(student child[], int&);        //the function to add a student
void saveRecords(student child[], int&);      //the function to save a record
void loadRecords(student child[], int&);      //the function to load a record
void searchStudent(student[], int&);    //the function to search a student

void printResultSheet(const student[], double[][3]);         //Prints the result sheet
void printSubjectSummary(const student[], double[][3]);      //Prints the subject summary

void gradeAnalysis(const student[], double[][3]);            //Prints the graph of grade analysis
void subjectAnalysis(const student[], double[][3]);          //Prints the graph of subject analysis

double meanCalculation(const student[], double[][3], int);                 //Calculate mean
double standardDeviationCalculation(const student[], double[][3], int);    //Calculate standard deviation
int calculateGradeCount(const student[], double[][3]);                     //Calculate the grade count
double calculateZScore(student[], const double[][3], int);                 //Calculate the z score

/*************************************************************
*                         Main method                        *
*                                                            *
**************************************************************/
int main()
{
    student child[MAX_NO_OF_STUDENTS];
    int currentStudentCount = 0;      //keeps the current student count
    int choice = 0;                   //keeps the input value given by the user in tha main menu

    choice = mainMenu();

    do{
        switch (choice)
        {
            case 1 : addStudent(child, currentStudentCount);  // Error Start Place
                     currentStudentCount++;
                     break;

            case 2 : saveRecords(child, currentStudentCount);
                     break;

            case 3 : loadRecords(child, currentStudentCount);
                     break;

            case 4 : searchStudent(child, currentStudentCount);
                     break;

            case 5 : reportSubMenu();
                     break;

            case 6 : graphSubMenu();
                     break;

            case 7 : exit(0);

            default : cout << "Enter a valid number. " << endl;

        }

    } while (choice < 8);

    return 0;
}

/*************************************************************
*           Function declaration of Main Menu                *
*                                                            *
**************************************************************/

int mainMenu()
{
    system("cls");
    int number = 0;

    cout << char(201) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(187) << endl;
    cout << char(186) << "       Main Menu       " << char(186) << endl;
    cout << char(186) << " " << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << " " << char(186) << endl;
    cout << char(186) << "                       " << char(186) << endl;
    cout << char(186) << "  [1] Add Student      " << char(186) << endl;
    cout << char(186) << "  [2] Save Records     " << char(186) << endl;
    cout << char(186) << "  [3] Load Records     " << char(186) << endl;
    cout << char(186) << "  [4] Search Student   " << char(186) << endl;
    cout << char(186) << "  [5] Print Reports    " << char(186) << endl;
    cout << char(186) << "  [6] Print Graphs     " << char(186) << endl;
    cout << char(186) << "  [7] Exit             " << char(186) << endl;
    cout << char(186) << "                       " << char(186) << endl;
    cout << char(200) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(188) << endl;

    cout << "\nEnter your choice [1-7] : " ;
    cin >> number ;

    return number;
}


/*************************************************************
*        Function declaration of Report Sub Menu             *
*                                                            *
**************************************************************/

void reportSubMenu()
{
    student child[MAX_NO_OF_STUDENTS];
    system("cls");
    int number = 0;

    cout << "\n" << endl;
    cout << char(201) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(187) << endl;
    cout << char(186) << "      Report Sub Menu      " << char(186) << endl;
    cout << char(186) << " " << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << " " << char(186) << endl;
    cout << char(186) << "                           " << char(186) << endl;
    cout << char(186) << " [1] Print Result Sheet    " << char(186) << endl;
    cout << char(186) << " [2] Print Subject Summary " << char(186) << endl;
    cout << char(186) << " [3] Back to Main Menu     " << char(186) << endl;
    cout << char(186) << "                           " << char(186) << endl;
    cout << char(200) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(188) << endl;

    cout << "\nEnter your choice [1-7] : " ;
    cin >> number ;

    switch (number)
    {
        case 1 : printResultSheet(child, result);
                 break;

        case 2 : printSubjectSummary(child, result);
                 break;

        case 3 : mainMenu();
                 break;

        default : cout << "Enter a valid number. ";
    }
}

/*************************************************************
*        Function declaration of Graph Sub Menu              *
*                                                            *
**************************************************************/

void graphSubMenu()
{
    student child[MAX_NO_OF_STUDENTS];
    system("cls");
    int number = 0;

    cout << "\n" << endl;
    cout << char(201) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(187) << endl;
    cout << char(186) << "      Graph Sub Menu     " << char(186) << endl;
    cout << char(186) << " " << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << " " << char(186) << endl;
    cout << char(186) << "                         " << char(186) << endl;
    cout << char(186) << " [1] Graph Analysis      " << char(186) << endl;
    cout << char(186) << " [2] Subject Analysis    " << char(186) << endl;
    cout << char(186) << " [3] Back to Main Menu   " << char(186) << endl;
    cout << char(186) << "                         " << char(186) << endl;
    cout << char(200) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205)
         << char(205) << char(205) << char(188) << endl;

    cout << "\nEnter your choice [1-3] : " ;
    cin >> number ;

    switch (number)
    {
        case 1 : gradeAnalysis(child, result);
                 break;

        case 2 : subjectAnalysis(child, result);
                 break;

        case 3 : mainMenu();
                 break;

        default : cout << "Enter a valid number. ";
    }
}

/*************************************************************
*        Function declaration of adding a student            *
*                                                            *
**************************************************************/

int addStudent(student child[], int currentCount)
{
    return 0;

}

/*************************************************************
*        Function declaration of saving a record             *
*                                                            *
**************************************************************/

void saveRecords(struct student students[], int currentCount)
{

}

/*************************************************************
*        Function declaration of loading a record            *
*                                                            *
**************************************************************/

void loadRecords(struct student students[], int currentCount)
{

}

/*************************************************************
*      Function declaration of searching a student           *
*                                                            *
**************************************************************/

void searchStudent(struct student students[], int currentCount)
{

}

/*************************************************************
*      Function declaration of printing result sheet         *
*                                                            *
**************************************************************/

void printResultSheet(struct student students[], double marks[][3])
{

}

/*************************************************************
*      Function declaration of printing subject summary      *
*                                                            *
**************************************************************/

void printSubjectSummary(struct student students[], double marks[][3])
{

}

/*************************************************************
*      Function declaration of graph of grade analysis       *
*                                                            *
**************************************************************/

void gradeAnalysis(struct student students[], double marks[][3])
{
    system("cls");
    cout << "\n" << endl;
    cout << "    Grade Analysis    " << endl;
    cout << " ==================== " << endl;
    cout << char(176) << endl;
    cout << char(177) << endl;
    cout << char(178) << endl;
}

/*************************************************************
*    Function declaration of graph of subject analysis       *
*                                                            *
**************************************************************/

void subjectAnalysis(struct student students[], double marks[][3])
{
    system("cls");
    cout << "\n" << endl;
    cout << "    Subject Analysis    " << endl;
    cout << " ====================== " << endl;
    cout << char(176) << endl;
    cout << char(177) << endl;
    cout << char(178) << endl;

}

/*************************************************************
*        Function declaration of calculating mean            *
*                                                            *
**************************************************************/

double meanCalculation(struct student students[], double marks[][3], int currentCount)
{
    return 50.0;

}

/*************************************************************
*  Function declaration of claculating standard deviation    *
*                                                            *
**************************************************************/

double standardDeviationCalculation(struct student students[], double marks[][3], int currentCount)
{
    return 100.0;

}

/*************************************************************
*    Function declaration of calculating grade count         *
*                                                            *
**************************************************************/

int calculateGradeCount(struct student students[], double marks[][3])
{
    return 50;

}

/*************************************************************
*        Function declaration of Calculating Z Score         *
*                                                            *
**************************************************************/

double calculateZScore(struct student students[], const double marks[][3], int currentCount)
{
    return 3.0256;


}

推荐答案

You are getting link errors and if you examine them carefully they will tell you the problem.



For example your declaration:



You are getting link errors and if you examine them carefully they will tell you the problem.

For example your declaration:

int addStudent(student child[], int&);





does not match implementation:





does not match implementation:

int addStudent(student child[], int currentCount)
{
    return 0;
 
}





meaning that there is nothing to link to for your call to



meaning that there is nothing to link to for your call to

case 1 : addStudent(child, currentStudentCount);  // Error Start Place





and etc and etc.



and etc and etc.


这篇关于未定义的数组访问问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆