Hello
I am in a difficulty in finding the size of array.
In following program I am passing the arraysize and the array as a parameters. Instead of doing that can I find the array size in the method?
template <class T, typename ReturnType = float>
class TEnterImp
{
public:
typedef ReturnType (T::*TemplateMethod)(void);
void enter(TemplateMethod *m_TemplateMethods, int arraySize)
{
ReturnType r =
for (int i =0; i < arraySize; i++ )
{
r = (state.*m_TemplateMethods[i])();
}
}
};
// This is how i call
float (MenuState::*p_menuStateFunctions[2])() = {NULL};
p_menuStateFunctions[0] = &MenuState::initSetup;
p_menuStateFunctions[1] = &MenuState::createGUI;
TEnterImp<MenuState, float> t;
t.enter(*this, p_menuStateFunctions, 2 );
I have tried following macro
#define length(a) ( sizeof ( a ) / sizeof ( *a ) )
length ( p_menuStateFunctions );
but it gives me 0
help please