При подготовке карты компилятор выдает prog.cc:16:17: error: no match function для вызова 'std:
Мои вопросы:
- Разумно ли использовать std::map для описанной цели?
- Почему пример кода выдает ошибку, и это очевидно
- Как исправить код?
Спасибо!
#include
typedef int (*t_handler)(int,int);
// Gives the same result: using t_handler = int (*)(int,int);
int product(int u, int v) {
return u*v;
}
// Map numeric ID to a function
std::map myMap;
int main() {
// Define 100 as the function to calculate the product
myMap.insert(100, &product); // prog.cc:16:17: error: no matching function for call to 'std:
// Calculate 5*8
int x = myMap[100](5, 8);
return 0;
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... n-handlers
Мобильная версия