+2  A: 

That's because you are trying to use incompatible pointers. setVector3 is a TShader method but send_to_shader wants a TShaderParam method.

Not knowing exactly what you want, you can get your example to compile by changing this:

void (TShaderParam::*send_to_shader)( const TParam&,const std::string&);

to this:

void (TShader::*send_to_shader)( const TParam&,const std::string&);
R Samuel Klatchko
+1  A: 

Presumably TShader::send_to_shader is a c-style function pointer?

Member functions cannot be used as function pointer callbacks - they require a this parameter.

Static member functions and global functions can be used as function pointers.

So you can either

  1. pass the this manually as a parameter to a static function callback, which in turn invokes the member function on the appropriate instance

  2. use an interface instead of a function

  3. use a functor

All three require slight architectural changes.

Will
C++0x will allow casts from free function pointer to PTMF, I suppose requiring generation of a functor. But I don't think that's the problem his error message indicates.
Potatoswatter
A: 

Pointers to member functions are a bit rigid. It would help if you showed us the line of code that generates the error, but just looking at it,

Error 2 error C2440: '=' :can't make the conversion 'void (__thiscall TShader::* )(const D3DXVECTOR3 &,const std::string &)' a 'void (__thiscall TShaderParam::* )(const TParam &,const std::string &)' c:\users\isagoras\documents\mcv\afoc\shader.cpp 127

So you've passed a void (TShader::* )(const D3DXVECTOR3 &,const std::string &) but someone expects a void (TShaderParam::* )(const TParam &,const std::string &).

You need to reimplement setVector3 as a method of a type derived from TShaderParam and extract your D3DXVECTOR3 & from the first argument, which must be a TParam. (But if it's just passing back your own value, you can static_cast it to your own type derived from TParam.)

Hope this helps!

Potatoswatter