Bonjour,

Ce post fait suite au problème suivant...

Mon nouveau problème est lors de l’utilisation d'un foncteur :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
 
template <typename T>
class A
{
public:
 
    typedef T (A<T>::*InterpolationFunc)(float, float, float) const;
 
    void MA(InterpoaltionType type)
    {
       // choix de la bonne fonction d'interpolation
        InterpolationFunc interpFunc = selectInterpoaltion(type); 
 
      // PROBLEME ICI
       T val = interFunc(0.0, 0.0, 0.0); 
    }
 
    InterpolationFunc selectInterpoaltion(InterpoaltionType type)
   {
        switch(type)
        {
         case 1 : return &A::interpolation1;
         case 2 : return &A::interpolation2;
         ...
         case N : return &A::interpolationN;
        }
   }
 
    virtual T interpolation1(float, float, float) const = 0;
    virtual T interpolation2(float, float, float) const = 0;
    ...
    virtual T interpolationN(float, float, float) const = 0;
};
 
template <typename T>
class B : public A<float>
{
    float  interpolation1(float, float, float) const { cout << "interpoaltion 1" << endl; return 0.0; }
    float interpolation2(float, float, float) const { cout << "interpoaltion 2" << endl; return 0.0; }
    ...
    float interpolationN(float, float, float) const { cout << "interpoaltion N" << endl; return 0.0; }
};
Lors de la compilation, j'ai l'erreur suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘interFunc (...)’, e.g. ‘(... ->* interFunc) (...)
Je ne comprends pas ce message d'erreur : j'ai l'impression que le compilateur s'attend a ce que interFunc soit une propriété de la classe alors que c'est plutôt un foncteur local sur une méthode de la classe ...

Une idée quelqu'un ?

Merci d'avance