Undefined reference to info()

Viewed 46

So basically I was given an assignment to write a program that uses three arrays, one to store the given names and the other two to output whether an Employ will be an Attendee at a conference. The employee is allowed to attend both sessions. (We are not allowed to use pointers, referencing or structs)

This is what I have written so far but I get the error:

undefined reference to `info(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, int, int)'

Any tips on how to fix it?

#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
#include <stdio.h>

using namespace std;

//Function initialization
bool info(string Names[10], int num, int pos);
void display(string Names[10], bool sesA[10], bool sesB[10]);
void totalAttendees(bool tempA[10], bool tempB[10]);

//Main program
int main() {

    //Variable declaration
    string arrNames[10] = {"Cindy Hess", "David Thornton", "Amanda Bryan", "Claudia Newton", "Heather Snyder", "Amy Rodriguez", "Kerry Ellis", "Yolanda Mccullough", "Summer Price", "Sandra Carter"};
    bool SessionA[10], SessionB[10];
    char choice, ses;
    int att, ctr, session;
    ctr = 0;

    //Input loops for SessionA & SessionB
    for (int i = 0; i < 10; i++) {
        SessionA[i] = info(arrNames, ctr, i);
    }
    ctr++;
    for (int i = 0; i < 10; i++) {
        SessionB[i] = info(arrNames, ctr, i);
    }

    //While loop for editing SessionA & SessionB
    cout << "Would you like to edit a session?(Y-yes / N-no): ";
    cin >> choice;
    while (toupper(choice) == 'Y') {
        cout << "Which Attendee would you like to edit: ";
        cin >> att;
        cout << "Which Session would you like to edit(A / B): ";
        cin >> ses;
        cout << "Update session(1-accept / 2-decline): ";
        cin >> session;

        if (toupper(ses) == 'A') {

            if (session == 1) {
                SessionA[att] = true;
            }
            else if (session == 2) {
                SessionA[att] = false;
            }
        }
        else if (toupper(ses) == 'B') {

            if (session == 1) {
                SessionB[att] = true;
            }
            else if (session == 2) {
                SessionB[att] = false;
            }
        }

        cout << "Would you like to edit a session?(Y-yes / N-no): ";
        cin >> choice;
    }

    totalAttendees(SessionA, SessionB);

    return 0;
}

//Info Function
bool info (string Names, int num, int pos) {
    string s;
    bool choice;

    if (num == 0) {
        s = "SESSION A";
    }
    else if (num == 1) {
        s = "SESSION B";
    }

    cout << (pos + 1) << ". " << Names[pos] << "are they going to attend " << s << "(1-accept / 2-decline): ";
    cin >> num;

    if (num == 1) {
        choice = true;
    }
    else if (num == 2) {
        choice = false;
    }

    return choice;
}

//Display Function
void display (string Names[10], bool sesA[10], bool sesB[10]) {
    cout << "#  " << "Attendee\t\t" << "Session A\t" << "Session B" << endl;
    for (int i = 0; i < 10; i++) {
        printf("%n. %2s %10b %5b\n", i + 1, Names[i], sesA[i], sesB[i]);
    }
}

//Total attendees function
void totalAttendees (bool sesA[10], bool sesB[10]) {
    int total = 0;

    for (int i = 0; i < 10; i++) {
        if (sesA[i] == true && sesB[i] == true) {
            total++;
        }
        else if (sesA[i] == true) {
            total++;
        }
        else if (sesB[i] == true) {
            total++;
        }
    }
    cout << "The total Attendees: " << total;
}
1 Answers

You are just missing this - [10] in your function definition.

//Info Function
bool info(string Names[10], int num, int pos) {
 ...
}
Related