I am writing a program for an assignment for a post fix calculator. There are bonus points if I can do it without using an if statement (no switch or while or any comparisons). I was reading about function pointers and came up with the following code:
int main(){
unordered_map<char,int*(int,int)> m;
m.insert({'+',[](int const a, int const b){return a+b;}});
}
This doesn't work.
However this does:
int main(){
unordered_map<char,int(*)(int,int)> m;
m.insert({'+',[](int const a, int const b){return a+b;}});
}
Why are (*) and * different?
Aucun commentaire:
Enregistrer un commentaire