?
Hier ist mal eine "50 Zeilen"-Lösung als Beispiel, wie man es auch hätte implementieren können.
#include <iostream>
#include <map>
#include <string>
#include <utility>
using std::cout;
using std::cin;
using std::map;
using std::string;
using std::pair;
using std::make_pair;
double my_add(double a, double b) {return a+b;}
double my_sub(double a, double b) {return a-b;}
double my_mul(double a, double b) {return a*b;}
double my_div(double a, double b) {return a/b;}
typedef double binfun_t(double,double);
int main()
{
// Operator-Zeichen --> Funktion X Beschreibung
typedef map<string,pair<binfun_t*,string> > bomap_t;
bomap_t binops;
binops["+"] = make_pair(&my_add,"Addition");
binops["-"] = make_pair(&my_sub,"Subtraktion");
binops["*"] = make_pair(&my_mul,"Multiplikation");
binops["/"] = make_pair(&my_div,"Division");
for (;;) {
cout << "Was willst Du machen?\n";
for (bomap_t::iterator beg=binops.begin(),
end=binops.end();
beg!=end; ++beg)
{
cout << beg->first << " (" << beg->second.second << ")\n";
}
cout << "(Abbruch ueber andere Eingabe)\n";
string eingabe;
if (!(cin >> eingabe)) break;
bomap_t::iterator it = binops.find(eingabe);
if (it==binops.end()) break;
binfun_t* bf = it->second.first;
double a, b;
cout << it->second.second << " von Zwei zahlen:\n";
if (!(cin >> a)) break;
if (!(cin >> b)) break;
cout << a << it->first << b << '=' << bf(a,b) << "\n\n";
}
}
HTH,
SP