0

I have multiple files with a main driver below calling functions in a header file then going to a .cpp file. However I am getting an undefined reference on moneyCout() and choice(number) shown here:

#include <iostream>
#include<stdlib.h>
#include<fstream>
#include "Menu.h"
#include "Gates.h"
#include "Money.h"
#include "Lot.h"

using namespace std;

void moneyCount();

int main()
{

    std::ifstream infile;
    infile.open("parking_account.txt");
    while(!infile.eof())
    {
        cin>>TotalBills>>ones>>fives>>tens>>twen>>quar;
    }
    infile.close();
    int number;
   cout<<"----------------------------------------------------\n\n"
    <<"------------------------------------------\n------------------------------------------------------\n"
    <<"                     Parking Machine Accounts\n"
    <<"-------------------------------------------------------------------\n------------------------------------------------------------\n"
    <<"Sr. No. : BILL NAME                  : BILL COUNT : COST(in $)\n"
    <<"------------------------------------------------------------------------\n";
    moneyCount();
    cout<<"Which Gate to enter?\n"
    <<"1  Gate A\n"
    <<"2  Gate B\n"
    <<"3  Gate C\n"
    <<"4  Report to file\n"
    <<"5  Exit\n"
    <<"Gate option(1-3):  ";
    cin>>number;
    choice(number);
}

The header file looks like

#ifndef MENU_H_INCLUDED
#define MENU_H_INCLUDED
#include "Money.h"
#include "Gates.h"
void choice(int choice);
void menu_2_A(int choice);
void menu_3(int choice);
void costMenu(int cost);


#endif // MENU_H_INCLUDED

the .cpp file for this header is

#include "Menu.h"
#include "Gates.h"
#include <stdlib.h>
#include <fstream>
#include <iostream>

void choice(int choice)
{
if(choice!=5)
{
    if (choice==1)
        Gate_A();
    if (choice == 2)
        Gate_B();
    if (choice==3)
        Gate_C();
    if (choice==4)
    {
        int x =rand() % 29+1;
        std::ofstream ReadMe;
        ReadMe.open("Parking_Information.txt");
        ReadMe<<"Visitors : "<<visit<<"\n";
        ReadMe<<"Total Emergency : "<<x<<"\n";
        ReadMe<<"Cash at the end of Today : "<<total_credit;
        ReadMe<<"Cash from Machine : "<<totalcred;
    }
}
}
void menu_2_A(int choice){
if(choice!=3){
if(choice==1){
park_lot();

}
if(choice==2)
    park_lot_dist();
}
}
void menu_3(int choice){
    if(choice!=3){
if (choice==1)
    costMenu(cost);
    if(choice==2)
        pay_for_spot(totalcred);
    }


}
void costMenu(int cost){
    int code;
    cash cash;
        double total_bills_1= 400;
        double total_ones= total_bills_1*cash.ones;
    double total_bills_5=300;
        double total_fives= total_bills_5*cash.fives;
    double total_bills_10= 200;
    double total_tens=total_bills_10*cash.tens;
    double total_bills_20 = 50;
    double total_20=total_bills_20*cash.twentys;
    double total_bills_quarters= 500;
    double total_quarters=total_bills_quarters*cash.quarters;
    int total_number_bills = 5;
    double total_credit= total_20+total_fives+total_ones+total_quarters+total_tens;
    if((total_bills_10==0)||(total_bills_1==0)||(total_bills_20==0)||(total_bills_5==0))
    total_number_bills--;
    if(cost<totalcred){
    std::cout<<"Please enter Cash.\n-----------------------------------------------------------------------------\n"
    <<"                                            Currency Denominations to Choose\n"
    <<" Code: Type \n"
    <<"  1 : One Dollar        \n"
    <<"  2 : Five Dollar        \n"
    <<"  3 : Ten Dollar        \n"
    <<"  4 : Twenty Dollar     \n"
    <<"  5 : Quarter       \n"
    <<"----------------------------------------------------------------------\n"
    <<"Enter code to credit ";
    std::cin>>code;
    if(code==1){
            totalcred+=cash.ones;
            total_bills_1++;
            total_ones++;
            total_number_bills++;
    }
    if(code==2){
        totalcred+=cash.fives;
        total_fives+=5;
        total_bills_5++;
        total_number_bills++;
    }
    if(code==3){
        totalcred+=cash.tens;
        total_tens+=10;
        total_bills_10++;
        total_number_bills++;
    }
    if(code==4){
        totalcred+=cash.twentys;
        total_20+=20;
        total_bills_20++;
        total_number_bills++;
    }
    if(code==5){
        totalcred+=cash.quarters;
        total_quarters+=0.25;
        total_bills_quarters++;
    }

}
std::cout<<"\nTotal Credit Availiable :"<<totalcred;
print_updated_list(totalcred);
std::cout<<"\nEnter a valid number below: \n\n"
            <<"1. Insert Cash\n"
            <<"2. Allot a Parking space\n"

            <<"3. Exit\n"
            <<"Enter Option:(1-2) ";
            int number;
            std::cin>>number;
            if(number<1||number >3){
                std::cout<<"Not Valid number. Enter Valid Number\n"
            <<"1. Insert Cash\n"
            <<"2. Allot a Parking space\n"

            <<"3. Exit\n"
            <<"Enter Option:(1-2) ";
            }
            menu_3(number);
}

here is the money.h file:

#define MONEY_H_INCLUDED




int TotalBills;
int ones,fives,tens,twen,quar;
int cost;
double total_credit;
struct cash{
double ones=1.00;
double fives=5.00;
double tens=10.00;
double twentys=20.00;
double quarters=0.25;
};

double totalcred=0.0;
void moneyCount();
void print_updated_list(double money);

double pay_for_spot(double money);

bool CheckCost_1(); //check to see if less than 50
bool CheckCost_2(); // check to see if less than 25


#endif // MONEY_H_INCLUDED:

this is the .cpp: #include "Menu.h" #include #include "Money.h" #include "Gates.h"

void moneyCount(){
    cash cash;

double total_bills_1= ones;
double total_ones= total_bills_1*cash.ones;
double total_bills_5=fives;
double total_fives= total_bills_5*cash.fives;
double total_bills_10= tens;
double total_tens=total_bills_10*cash.tens;
double total_bills_20 = twen;
double total_20=total_bills_20*cash.twentys;
double total_bills_quarters= quar;
double total_quarters=total_bills_quarters*cash.quarters;
int total_number_bills = TotalBills;
double total_credit= total_20+total_fives+total_ones+total_quarters+total_tens;
if((total_bills_10==0)||(total_bills_1==0)||(total_bills_20==0)||(total_bills_5==0))
    total_number_bills--;

std::cout<<"  1 : One Dollar               :   "<<total_bills_1<<"    :    "<<total_ones<<"\n"
   <<"  2 : Five Dollar              :   "<<total_bills_5<<"    :    "<<total_fives<<"\n"
    <<"  3 : Ten Dollar               :   "<<total_bills_10<<"    :    "<<total_tens<<"\n"
    <<"  4 : Twenty Dollar            :   "<<total_bills_20<<"     :    "<<total_20<<"\n"
    <<"  5 : Quarter                  :   "<<total_bills_quarters<<"    :    "<<total_quarters<<"\n"
    <<"----------------------------------------------------------------------\n"
    <<"Number of Bill Types: "<<total_number_bills<<"\n";
    total_credit=total_credit+totalcred;
    std::cout<<"Total Credit: "<<total_credit<<"\n\n";
}



bool CheckCost_1(){
bool temp=false;
if(max_avai<50)
    temp=true;
return temp;

}
bool CheckCost_2(){
    bool temp=false;
if(max_avai<25)
    temp=true;
return temp;
}
void print_updated_list(double money){
cash cash;
double total_bills_1= 400;
double total_ones= total_bills_1*cash.ones;
double total_bills_5=300;
double total_fives= total_bills_5*cash.fives;
double total_bills_10= 200;
double total_tens=total_bills_10*cash.tens;
double total_bills_20 = 50;
double total_20=total_bills_20*cash.twentys;
double total_bills_quarters= 500;
double total_quarters=total_bills_quarters*cash.quarters;
int total_number_bills = 5;
double total_credit= total_20+total_fives+total_ones+total_quarters+total_tens;
if((total_bills_10==0)||(total_bills_1==0)||(total_bills_20==0)||(total_bills_5==0))
    total_number_bills--;

std::cout<<" \n 1 : One Dollar               :   "<<total_bills_1<<"    :    "<<total_ones<<"\n"
   <<"  2 : Five Dollar              :   "<<total_bills_5<<"    :    "<<total_fives<<"\n"
    <<"  3 : Ten Dollar               :   "<<total_bills_10<<"    :    "<<total_tens<<"\n"
    <<"  4 : Twenty Dollar            :   "<<total_bills_20<<"     :    "<<total_20<<"\n"
    <<"  5 : Quarter                  :   "<<total_bills_quarters<<"    :    "<<total_quarters<<"\n"
    <<"----------------------------------------------------------------------\n"
    <<"Number of Bill Types: "<<total_number_bills<<"\n"
    <<"Total Credit: "<<total_credit+totalcred<<"\n\n";

}
double pay_for_spot(double money){
cash cash;
double total_bills_1= 400;
double total_ones= total_bills_1*cash.ones;
double total_bills_5=300;
double total_fives= total_bills_5*cash.fives;
double total_bills_10= 200;
double total_tens=total_bills_10*cash.tens;
double total_bills_20 = 50;
double total_20=total_bills_20*cash.twentys;
double total_bills_quarters= 500;
double total_quarters=total_bills_quarters*cash.quarters;
int total_number_bills = 5;
double total_credit= total_20+total_fives+total_ones+total_quarters+total_tens;
if((total_bills_10==0)||(total_bills_1==0)||(total_bills_20==0)||(total_bills_5==0))
    total_number_bills--;
double change=0.0;
if((money!=0)&&(money>-1)){
if(money-20>=0){
    change+=cash.twentys;
    total_20-=20;
    total_bills_20--;
    }
if(money-10>=0){
    change+=cash.tens;
    total_tens-=10;
    total_bills_10--;
}
if(money-5>=0){
    change+=cash.fives;
    total_bills_5--;
    total_fives-=5;
}
if(money-1>=0){
    change+=cash.ones;
    total_bills_1--;
    total_ones--;
}
if(money-.025>=0){
    change+=cash.quarters;
    total_bills_quarters--;
    total_quarters-=0.25;
}

std::cout<<"\nGate is open your change is $"<<change;
print_updated_list(change);
}
std::cout<<"\nGate is open\n";
    int number;
   std::cout<<"----------------------------------------------------\n\n"
    <<"------------------------------------------\n------------------------------------------------------\n"
    <<"                     Parking Machine Accounts\n"
    <<"-------------------------------------------------------------------\n------------------------------------------------------------\n"
    <<"Sr. No. : BILL NAME                  : BILL COUNT : COST(in $)\n"
    <<"------------------------------------------------------------------------\n";
    moneyCount();
    std::cout<<"Which Gate to enter?\n"
    <<"1  Gate A\n"
    <<"2  Gate B\n"
    <<"3  Gate C\n"
    <<"4  Report to file\n"
    <<"5  Exit\n"
    <<"Gate option(1-3):  ";
    std::cin>>number;
    choice(number);

}

gates.h:

#ifndef GATES_H_INCLUDED
#define GATES_H_INCLUDED
#include "Lot.h"
#include "Money.h"
struct park{
int maxi;
int avai;
double cost;
int dist;
};
void Gate_A(); //gate a
void Gate_B(); //gate b
void Gate_C(); // gate c

int visit=0;
int max_park= 290;
int max_avai=176;
#endif // GATES_H_INCLUDED

Gates.cpp

#include "Menu.h"
#include "Gates.h"
#include "Lot.h"
#include "Money.h"
#include <iostream>

void Gate_A(){
    int visit=0;
    visit++;
     park park_A;
    park park_B;
    park park_C;
    park park_D;
    park park_E;
    park park_F;
    park park_G;
    park park_H;
    park park_I;
    park_A.maxi=40;
    park_A.avai=27;
    park_A.cost=25.00;
    park_A.dist=10;
    park_B.maxi=20;
    park_B.avai=7;
    park_B.cost=22.50;
    park_B.dist=20;
    park_C.maxi=50;
    park_C.avai=38;
    park_C.cost=20.00;
    park_C.dist=30;
    park_D.maxi=30;
    park_D.avai=11;
    park_D.cost=22.5;
    park_D.dist=20;
    park_E.maxi=55;
    park_E.avai=41;
    park_E.cost=20.00;
    park_E.dist=20;
    park_F.maxi=15;
    park_F.avai=7;
    park_F.cost=17.50;
    park_F.dist=40;
    park_G.maxi=20;
    park_G.avai=13;
    park_G.cost=20.00;
    park_G.dist=30;
    park_H.maxi=33;
    park_H.avai=21;
    park_H.cost=17.5;
    park_H.dist=40;
    park_I.maxi=27;
    park_I.avai=11;
    park_I.cost=15.00;
    park_I.dist=50;
    park_lot();
    if(CheckCost_1()==true){
    park_A.cost+=5.75;
    park_B.cost+=5.75;
    park_C.cost+=5.75;
    park_D.cost+=5.75;
    park_E.cost+=5.75;
    park_F.cost+=5.75;
    park_G.cost+=5.75;
    park_H.cost+=5.75;
    park_I.cost+=5.75;
    }
    if(CheckCost_2()==true){
    park_A.cost+=7.25;
    park_B.cost+=7.25;
    park_C.cost+=7.25;
    park_D.cost+=7.25;
    park_E.cost+=7.25;
    park_F.cost+=7.25;
    park_G.cost+=7.25;
    park_H.cost+=7.25;
    park_I.cost+=7.25;
    }
       std::cout<<"-------------------------------------------------------------------\n\n\n"
        <<"------------------------------------------------------------------\n"
        <<"                         Gate A : Lot Information\n"
        <<"------------------------------------------------------------------\n"
        <<" LOT ID : MAX CAPACITY :          AVAILIABLE SPOTS : COST(IN $) : DISTANCE\n"
        <<"------------------------------------------------------------------\n";
for(char i='A';i<'J';i++){
    if(i=='A')
        std::cout<<i<<"       : "<<park_A.maxi<<" : "<<"       "<<park_A.avai<<" : "<<park_A.cost<<" : "<<park_A.dist<<"\n\n";
    if(i=='B')
        std::cout<<i<<"       : "<<park_B.maxi<<" : "<<"       "<<park_B.avai<<" : "<<park_B.cost<<" : "<<park_B.dist<<"\n\n";
    if(i=='C')
        std::cout<<i<<"       : "<<park_C.maxi<<" : "<<"       "<<park_C.avai<<" : "<<park_C.cost<<" : "<<park_C.dist<<"\n\n";
    if(i=='D')
        std::cout<<i<<"       : "<<park_D.maxi<<" : "<<"       "<<park_D.avai<<" : "<<park_D.cost<<" : "<<park_D.dist<<"\n\n";
    if(i=='E')
        std::cout<<i<<"       : "<<park_E.maxi<<" : "<<"       "<<park_E.avai<<" : "<<park_E.cost<<" : "<<park_E.dist<<"\n\n";
    if(i=='F')
        std::cout<<i<<"       : "<<park_F.maxi<<" : "<<"       "<<park_F.avai<<" : "<<park_F.cost<<" : "<<park_F.dist<<"\n\n";
    if(i=='G')
        std::cout<<i<<"       : "<<park_G.maxi<<" : "<<"       "<<park_G.avai<<" : "<<park_G.cost<<" : "<<park_G.dist<<"\n\n";
    if(i=='H')
        std::cout<<i<<"       : "<<park_H.maxi<<" : "<<"       "<<park_H.avai<<" : "<<park_H.cost<<" : "<<park_H.dist<<"\n\n";
    if(i=='I')
        std::cout<<i<<"       : "<<park_I.maxi<<" : "<<"       "<<park_I.avai<<" : "<<park_I.cost<<" : "<<park_I.dist<<"\n\n";
}
std::cout<<"Max Capacity: "<<max_park<<"      Max Available: "<<max_avai<<"\n\n\n\n"<<"Select A Criteria to Allot a parking space  :\n"
    <<"1. Based on cost-cheapest to allot a parking spot\n"
    <<"2. Based on Distance - Closest to stadium\n"
    <<"3. Return to main menu\n"
    <<"4.Exit\n"
    <<"Enter option (1-2) : ";
    int num;
    std::cin>>num;
    menu_2_A(num);
}
void Gate_B(){
    visit++;
    park park_A;
    park park_B;
    park park_C;
    park park_D;
    park park_E;
    park park_F;
    park park_G;
    park park_H;
    park park_I;
    park_A.maxi=40;
    park_A.avai=27;
    park_A.cost=25.00;
    park_A.dist=30;
    park_B.maxi=20;
    park_B.avai=7;
    park_B.cost=22.50;
    park_B.dist=40;
    park_C.maxi=50;
    park_C.avai=38;
    park_C.cost=20.00;
    park_C.dist=50;
    park_D.maxi=30;
    park_D.avai=11;
    park_D.cost=22.5;
    park_D.dist=20;
    park_E.maxi=55;
    park_E.avai=41;
    park_E.cost=20.00;
    park_E.dist=30;
    park_F.maxi=15;
    park_F.avai=7;
    park_F.cost=17.50;
    park_F.dist=40;
    park_G.maxi=20;
    park_G.avai=13;
    park_G.cost=20.00;
    park_G.dist=10;
    park_H.maxi=33;
    park_H.avai=21;
    park_H.cost=17.5;
    park_H.dist=20;
    park_I.maxi=27;
    park_I.avai=11;
    park_I.cost=15.00;
    park_I.dist=30;
    if(CheckCost_1()==true){
    park_A.cost+=5.75;
    park_B.cost+=5.75;
    park_C.cost+=5.75;
    park_D.cost+=5.75;
    park_E.cost+=5.75;
    park_F.cost+=5.75;
    park_G.cost+=5.75;
    park_H.cost+=5.75;
    park_I.cost+=5.75;
    }
    if(CheckCost_2()==true){
    park_A.cost+=7.25;
    park_B.cost+=7.25;
    park_C.cost+=7.25;
    park_D.cost+=7.25;
    park_E.cost+=7.25;
    park_F.cost+=7.25;
    park_G.cost+=7.25;
    park_H.cost+=7.25;
    park_I.cost+=7.25;
    }
    std::cout<<"-------------------------------------------------------------------\n\n\n"
        <<"------------------------------------------------------------------\n"
        <<"                         Gate B : Lot Information\n"
        <<"------------------------------------------------------------------\n"
        <<" LOT ID : MAX CAPACITY :          AVAILIABLE SPOTS : COST(IN $) : DISTANCE\n"
        <<"------------------------------------------------------------------\n";
for(char i='G';i<'J';i++){
    if(i=='G')
        std::cout<<i<<"       : "<<park_G.maxi<<" : "<<"       "<<park_G.avai<<" : "<<park_G.cost<<" : "<<park_G.dist<<"\n\n";
    if(i=='H')
        std::cout<<i<<"       : "<<park_H.maxi<<" : "<<"       "<<park_H.avai<<" : "<<park_H.cost<<" : "<<park_H.dist<<"\n\n";
    if(i=='I')
        std::cout<<i<<"       : "<<park_I.maxi<<" : "<<"       "<<park_I.avai<<" : "<<park_I.cost<<" : "<<park_I.dist<<"\n\n";
}
        for(char i='D';i<'G';i++){
    if(i=='D')
        std::cout<<i<<"       : "<<park_D.maxi<<" : "<<"       "<<park_D.avai<<" : "<<park_D.cost<<" : "<<park_D.dist<<"\n\n";
    if(i=='E')
        std::cout<<i<<"       : "<<park_E.maxi<<" : "<<"       "<<park_E.avai<<" : "<<park_E.cost<<" : "<<park_E.dist<<"\n\n";
    if(i=='F')
        std::cout<<i<<"       : "<<park_F.maxi<<" : "<<"       "<<park_F.avai<<" : "<<park_F.cost<<" : "<<park_F.dist<<"\n\n";
        }
        for (char i='A';i<'D';i++){
    if(i=='A')
        std::cout<<i<<"       : "<<park_A.maxi<<" : "<<"       "<<park_A.avai<<" : "<<park_A.cost<<" : "<<park_A.dist<<"\n\n";
    if(i=='B')
        std::cout<<i<<"       : "<<park_B.maxi<<" : "<<"       "<<park_B.avai<<" : "<<park_B.cost<<" : "<<park_B.dist<<"\n\n";
    if(i=='C')
        std::cout<<i<<"       : "<<park_A.maxi<<" : "<<"       "<<park_C.avai<<" : "<<park_C.cost<<" : "<<park_C.dist<<"\n\n";
}
std::cout<<"Max Capacity: "<<max_park<<"      Max Available: "<<max_avai<<"\n\n\n\n"<<"Select A Criteria to Allot a parking space  :\n"
    <<"1. Based on cost-cheapest to allot a parking spot\n"
    <<"2. Based on Distance - Closest to stadium\n"
    <<"3. Return to main menu\n"
    <<"4.Exit\n"
    <<"Enter option (1-2) : ";
    int num;
    std::cin>>num;
    menu_2_A(num);

}
void Gate_C(){
visit++;
    park park_A;
    park park_B;
    park park_C;
    park park_D;
    park park_E;
    park park_F;
    park park_G;
    park park_H;
    park park_I;
    park_A.maxi=40;
    park_A.avai=27;
    park_A.cost=25.00;
    park_A.dist=50;
    park_B.maxi=20;
    park_B.avai=7;
    park_B.cost=22.50;
    park_B.dist=40;
    park_C.maxi=50;
    park_C.avai=38;
    park_C.cost=20.00;
    park_C.dist=30;
    park_D.maxi=30;
    park_D.avai=11;
    park_D.cost=22.5;
    park_D.dist=40;
    park_E.maxi=55;
    park_E.avai=41;
    park_E.cost=20.00;
    park_E.dist=30;
    park_F.maxi=15;
    park_F.avai=7;
    park_F.cost=17.50;
    park_F.dist=20;
    park_G.maxi=20;
    park_G.avai=13;
    park_G.cost=20.00;
    park_G.dist=30;
    park_H.maxi=33;
    park_H.avai=21;
    park_H.cost=17.5;
    park_H.dist=20;
    park_I.maxi=27;
    park_I.avai=11;
    park_I.cost=15.00;
    park_I.dist=10;
if(CheckCost_1()==true){
    park_A.cost+=5.75;
    park_B.cost+=5.75;
    park_C.cost+=5.75;
    park_D.cost+=5.75;
    park_E.cost+=5.75;
    park_F.cost+=5.75;
    park_G.cost+=5.75;
    park_H.cost+=5.75;
    park_I.cost+=5.75;
    }
    if(CheckCost_2()==true){
    park_A.cost+=7.25;
    park_B.cost+=7.25;
    park_C.cost+=7.25;
    park_D.cost+=7.25;
    park_E.cost+=7.25;
    park_F.cost+=7.25;
    park_G.cost+=7.25;
    park_H.cost+=7.25;
    park_I.cost+=7.25;
    }
    std::cout<<"-------------------------------------------------------------------\n\n\n"
        <<"------------------------------------------------------------------\n"
        <<"                         Gate C : Lot Information\n"
        <<"------------------------------------------------------------------\n"
        <<" LOT ID : MAX CAPACITY :          AVAILIABLE SPOTS : COST(IN $) : DISTANCE\n"
        <<"------------------------------------------------------------------\n";
        for(char i='I';i>='A';i--){
    if(i=='I')
        std::cout<<i<<"       : "<<park_I.maxi<<" : "<<"       "<<park_I.avai<<" : "<<park_I.cost<<" : "<<park_I.dist<<"\n\n";
    if(i=='H')
        std::cout<<i<<"       : "<<park_H.maxi<<" : "<<"       "<<park_H.avai<<" : "<<park_H.cost<<" : "<<park_H.dist<<"\n\n";
    if(i=='G')
        std::cout<<i<<"       : "<<park_G.maxi<<" : "<<"       "<<park_G.avai<<" : "<<park_G.cost<<" : "<<park_G.dist<<"\n\n";
    if(i=='F')
        std::cout<<i<<"       : "<<park_F.maxi<<" : "<<"       "<<park_F.avai<<" : "<<park_F.cost<<" : "<<park_F.dist<<"\n\n";
    if(i=='E')
        std::cout<<i<<"       : "<<park_E.maxi<<" : "<<"       "<<park_E.avai<<" : "<<park_E.cost<<" : "<<park_E.dist<<"\n\n";
    if(i=='D')
        std::cout<<i<<"       : "<<park_D.maxi<<" : "<<"       "<<park_D.avai<<" : "<<park_D.cost<<" : "<<park_D.dist<<"\n\n";
    if(i=='C')
        std::cout<<i<<"       : "<<park_C.maxi<<" : "<<"       "<<park_C.avai<<" : "<<park_C.cost<<" : "<<park_C.dist<<"\n\n";
    if(i=='B')
        std::cout<<i<<"       : "<<park_B.maxi<<" : "<<"       "<<park_B.avai<<" : "<<park_B.cost<<" : "<<park_B.dist<<"\n\n";
    if(i=='A')
        std::cout<<i<<"       : "<<park_A.maxi<<" : "<<"       "<<park_A.avai<<" : "<<park_A.cost<<" : "<<park_A.dist<<"\n\n";
        }
std::cout<<"Max Capacity: "<<max_park<<"      Max Available: "<<max_avai<<"\n\n\n\n"<<"Select A Criteria to Allot a parking space  :\n"
    <<"1. Based on cost-cheapest to allot a parking spot\n"
    <<"2. Based on Distance - Closest to stadium\n"
    <<"4.Exit\n"
    <<"Enter option (1-2) : ";
    int num;
    std::cin>>num;
    menu_2_A(num);

}

lot.h

#ifndef LOT_H_INCLUDED
#define LOT_H_INCLUDED
#include "Gates.h"

int park_lot();
int park_lot_dist();


#endif // LOT_H_INCLUDED

once I resolve these errors the other errors should be similar to solve. thanks in advance.

2 Answers2

1

"Undefined reference" by the linker means that it cannot find the compiled code for those symbols. That generally means that they're not defined, or defined incorrectly. Let's dig in with your particular example.

For moneyCount, I don't see an actual definition, only a declaration. You have

void moneyCount();

That's good, but somewhere in one of your .cpp files, you need to provide a body for it. That is:

void moneyCount() {
  // your stuff here
}

For choice(number), you have defined a global function as:

void choice(int choice){
    // some stuff
}

but have declared it as an instance function

class menu{
public:
void choice(int choice);
// more stuff
}

For this, you should change your definition to be:

void menu::choice(int choice){
    // some stuff
}
kenrose
  • 186
  • 1
  • 5
0

First problem is:

You are getting an undefined reference error for the moneyCout() function because it doesn't exist as you didn't define the function.

Please learn how to define functions. std::ofstream ReadMe; should be defined in main( my preference ).

Please define moneycount function. Don't just initialize it!

Show us the gate functions in gate.cpp that might be the problem.

Remember to have the class and scope operator before each function in menu.cpp like this

void menu::choice(int) 
void menu::costMenu(int)

Last problem is, you actually have to create class object to refer to the functions in your class like this.

menu Menu;
Menu.choice(number);

Please correct all errors.

techuser soma
  • 4,766
  • 5
  • 23
  • 43