I'm writing a program for my dads bar downstairs, and im having trouble. Each section of the program has its own class, and each class has several functions declared within it. I havent been working on it long so its hard to follow the code because it isnt representing a finished thought.
The problem is that i need to pass the "Choice" variable from a function in one class to a function in a different class. I remember doing this in CS2 back two years ago, but i cant member anything beyond that.
I browesed through the FAQ and even some of my old code, but for some reason im not finding help LOL. Considering the opengl programming experience i have im amazed that i cant figure this out. Heres the sloppy code.
[code]Code:/* Bartender version 1.0 Build 1.0.0, 12/25/04 Steven Billington Wacker7 Inc. [email protected] */ /* List our include files that we will use throughout the program */ #include <stdio.h> #include <iostream> #include <stdlib.h> #include <string> using namespace std; /* User_Menu class contains all functions and variables the program will use to take in the users menu decision */ class User_Menu { public: void Disp_Options(); void User_Choice(); int Choice; }; class Choice_Catalog { public: void Prompt_Drink(); void Find_Drink(); void Disp_Drink(); string Drink_Name; }; class Choice_NewEntry { public: void Drink_Info(); void Save_Data(); void Disp_Result(); }; class Choice_Random { public: void Random_Drink(); void Disp_Drink(); }; class Choice_ListCatalog { public: void Display_All(); }; class Choice_About { public: void Software_Info(); }; class Choice_Exit { public: void Terminate(); }; /* Search_Catalog class contains all functions and variables that will be used to find specific drink entries in the database */ class Search_Catalog { public: void Load_Catalog(); void Search_For(); void Display(); }; /* Main defines the entry point for our application */ int main(int argc, char *argv[]) { /* Declare class objects*/ User_Menu Menu_Obj; Choice_Catalog Cata_Obj; /* Invoke disply function of User_Menu class*/ Menu_Obj.Disp_Options(); system("pause"); return 0; } /* Declare the Disp_Options function. This function lets us present options to the user */ void User_Menu::Disp_Options() { cout << "Bartender v1.0" << endl; cout << endl; cout << "1. Search Catalog" << endl; cout << "2. New Drink" << endl; cout << "3. Random Selection" << endl; cout << "4. Master Drink List" << endl; cout << "5. About Bartender v1.0" << endl; cout << "6. Exit Program" << endl; /* Call User_Choice function*/ User_Choice(); } /* Declare User_Choice function. With this function we allow the user to make a decision based on the choices we presented */ void User_Menu::User_Choice() { cout << endl << endl; cout << "Enter menu selection (1-6): "; cin >> Choice; cout << endl; switch (Choice) { case 1: Prompt_Drink(); break; case 2: Drink_Info(); break; case 3: Random_Drink(); break; case 4: Display_All(); break; case 5: Software_Info(); break; case 6: Terminate(); break; default: cout << "Invalid Entry, please retry."; cout << endl; Display_Options(); } } void Choice_Catalog::Prompt_Drink() { cout << endl << "Enter drink name: "; cin >> Drink_Name; //was testing something cout << "Name was: " << Drink_Name << endl; }