Help with calling header files in C++

Mar 8, 2013 at 6:04pm
This is a program that I have already written. What I need to do is modify my switch statement so it calls the header files instead of stating what the user chose. So, when the user chooses 1, the program calls cashier.h. If the user chooses 2, the program calls invmenu.h. If the user chooses 3, the program calls reports.h. I already have my header files set up, I just don't know to how write the code to call the header files. Thanks!

#include <iostream>
#include "bookinfo.h"
#include "cashier.h"
#include "invmenu.h"
#include "reports.h"
using namespace std; //indicate use of input and output

int main() { //define main function
int decision = 0;

while (decision != 4) { //adding a while; it will repeat until it gets 4.


cout << "Serendipity Booksellers" << endl; //start output text
cout << "Main Menu" << endl << endl;

cout << "1. Cashier Module" << endl;
cout << "2. Inventory Database Module" << endl;
cout << "3. Report Module" << endl;
cout << "4. Exit" << endl << endl;
cout << "Enter Your Choice [1-4] : "; //end output text
cin >> decision;
cin.ignore();

if ((decision < 1) || (decision > 4)) {
cout << "Please choose a number between 1 and 4."; //prompt user to input data

}

switch(decision) {
case 1:
cout << "You chose: Cashier Module" << endl;
break;
case 2:
cout << "You chose: Inventory Database Module" << endl;
break;
case 3:
cout << "You chose: Report Module" << endl;
break;
case 4:
cout << "You chose: Exit" << endl;
break;
default:
cout << "" << endl;
break;
}

}

cin.get();

return(0);
} //end main function
Mar 8, 2013 at 6:09pm
You cannot call a header file.
What you can do is to call a particular function in that file.
Mar 8, 2013 at 6:37pm
So I've learned. I need to call the function, but still don't know how to write the code for that.
My header files are:
cashier.h containing: int cashier();
invmenu.h containing: int invmenu();
reports.h containing: int reports();

I have source files for all of them
Mar 8, 2013 at 6:39pm
Example:
1
2
3
4
5
6
7
    switch (decision) 
    {
        case 1:
            cashier();
            break;
      // ... etc
    }
Topic archived. No new replies allowed.