0

I have 3 files for a small project that I'm working on. The files are main.cpp, Airline.h (This is where my classes are stored) and Airline.cpp (This is where my functions are stored).

As of now, when I test the code out, I get an error that says:

undefined reference to "programInformation::mainMenu()

Can anyone see if there's any issues in my files, and how I have my folders set up?

image

#include <iostream>
#include "AirlineClass.h"
using namespace std;

void programInformation::mainMenu(){
    cout << "      Welcome to DFW Airport     " << endl;
    cout << "=================================" << endl;
    cout << "------------Main Menu------------" << endl;
    cout << "1. Customer Details" << endl;
    cout << "2. Flight Registration " << endl;
    cout << "3. Ticket and Charges " << endl;
    cout << "4. Exit" << endl;
    cout << "Select Option" << endl;
    int option;
    cin >> option;

    switch(option){
        case 1:
        {
            customerInformation info;
            info.obtainInformation();
            info.displayInformation();
            break;
        }
        case 2:
        {
            
        }
        case 3:
        {

        }
        case 4:
        {

        }
    }

}
#ifndef AIRLINECLASS_AIRLINECLASS_H
#define AIRLINECLASS_AIRLINECLASS_H

#include <iostream>
#include <string>
using namespace std;

class programInformation
{
    public:
       void mainMenu();

};

class customerInformation
{
    private:
        string firstName;
        string lastName;
        string countryResidence;
        string gender;
        string birthday;
        int phoneNumber;
        int age;

    public:
        void obtainInformation()
        {
            cout << "Enter First Name" << endl;
            getline(cin, firstName);
            cout << "Enter Last Name" << endl;
            getline(cin, lastName);
            cout << "Enter Age" << endl;
            cin >> age;
            cout << "Enter Gender" << endl;
            getline(cin, gender);
            cout << "Enter Birthday in the following formation: MM/DD/YYYY" << endl;
            getline(cin, birthday);
            cout << "Enter Phone Number" << endl;
            cin >> phoneNumber;
            cout << "Enter Country of Residency" << endl;
            getline(cin, countryResidence);
        }
        void displayInformation()
        {
            cout << "     Passanger Information     " << endl;
            cout << "===============================" << endl;
            cout << "First Name - " << firstName << endl;
            cout << "Last Name - " << lastName << endl;
            cout << "Age - " << age << endl;
            cout << "Gender - " << gender << endl;
            cout << "Birthday mm/dd/yyyy - " << birthday << endl;
            cout << "Phone Number - " << phoneNumber << endl;
            cout << "Country of Residence - " << countryResidence << endl;
        }
};
#endif
#include <iostream>
#include "AirlineClass.h"
using namespace std;

int main()
{
    programInformation startProgram;
    startProgram.mainMenu();
    return 0;
}
user4581301
  • 33,082
  • 7
  • 33
  • 54
xRGx901x
  • 41
  • 4
  • 1
    Sounds like you are not linking airlineclass.cpp. – 001 May 04 '23 at 17:18
  • Also give [mre] a read. Often all you need to do to find and fix a problem is to remove everything not related to the problem from the code. – user4581301 May 04 '23 at 17:22
  • Remember that by default VSCode only builds the active file into your executable and it ignores all other files in your workspace. The documentation tells you this and how to modify your tasls.json to have it build all source files in your folder. You should see the exact build output in the terminal and that should show you that only 1 file was compiled. – drescherjm May 04 '23 at 18:00

0 Answers0