Can you call a function depending on which number an integer is?
Here's what I mean:
#include <iostream>
using namespace std;
int whichFunction;
int main()
{
cout << "Which function do you want to call?";
cin >> whichFunction;
function[whichFunction]();
//If you entered 1, it would call function1 - same with 2, 3
//or Hihihi (of course only when whichFunction would be a string)
}
void function1()
{
cout << "Function No. 1 was called!";
}
void function2()
{
cout << "Function No. 2 was called!";
}
void functionHihihi()
{
cout << "Function Hihihi was called!";
}
I know this doesn't work but I hope you get the idea.
So is there a way to do something like that?