Ik probeer een pointer naar een functie met templates te gebruiken als functie pointer, maar de compiler vind dit niet leuk.
Doe ik iets niet goed, ondersteund de compiler het niet of ondersteund c++ het niet?
Doe ik iets niet goed, ondersteund de compiler het niet of ondersteund c++ het niet?
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| class Cucr_container { }; template <class T> Cucr_container* new_container() { return new T; } Cucr_container* new_container_2() { return new Cucr_container; } typedef Cucr_container* (*t_new_container_f)(); int main() { t_new_container_f f_2 = new_container_2; t_new_container_f f = new_container<Cucr_container>; // 21 /* main.cpp(21) : error C2440: 'initializing' : cannot convert from '' to 'class Cucr_container *(__cdecl *)(void)' None of the functions with this name in scope match the target type */ return 0; } |