Normally I can find answers just by searching, this time however I think the question is a little too simple. I need to build an array of functions (pointers I think).
Ok, so I'm not the sharpest knife... Got to learn somehow.Code:#include <iostream> #include <stdlib.h> #include <fstream> #include <iomanip> #include <cstdlib> #include <ctype.h> void func1(); void func2(); void func3(); int main(){ using namespace std; //I don't know whow to make the next line work.. functions[3] = {func1, func2, func3}; int slct; while(slct != 9) { system("cls"); cout << "\t\t Menu:\n\n\t 1) Function 1\n\t 2) Function 2\n\t " << "3) Function 3\n\n 9) Exit\n\n Please enter your selection: "; switch(slct) { case 1: case 2: case 3: slct --; functions[slct](); break; case 9: cout << "Thank you!"; break; default: cout << "I'm sorry that is not a valid choice."; break; } } return 0; } func1(){ cout << "This is func1."; } func2(){ cout << "This is func2."; } func3(){ cout << "This is func3."; }
Thanks