I have the following class:
class DXStartupEncoder {
public:
void EncodeA(unsigned char*& message) const;
void EncodeB(unsigned char*& message) const;
void EncodeC(unsigned char*& message) const;
void EncodeD(unsigned char*& message) const;
};
<type> dn_sequence[] = {&DXStartupEncoder::EncodeA, &DXStartupEncoder::EncodeB, &DXStartupEncoder::EncodeC, &DXStartupEncoder::EncodeD };
But what is the type of this array of function pointers?
Use a
typedefif you are not sure.In C++11 you could use
decltypeto deduce the type from value, so you don’t even need to know how to write the type of a member function pointer (autocan’t work, because the right hand side is an initializer_list):If you need to avoid the
typedef, by the way, you’ll write it as: