I would like to replace a macro with a function / template:
#define FOO( f ) \
int result = m_Member.f; \
switch ( result ) \
{ \
case 1: \
m_pMember1->f; \
break;
case 2:
m_pMember2->f; \
break;
}
class foo
{
public:
void foo1(int x, int y)
{
FOO( foo1(x, y) )
}
void foo2(int x, double y, void *z)
{
FOO( foo2(x, y) )
}
protected:
fooA m_Member;
fooB m_Member1;
fooC m_Member2;
};
So my problem is that function name is passed to a macro together with arguments. I can rewrite call to something like FOO( foo1, x, y ) and then deal with variable argument list. So macro will define just a single function call. But maybe there's a more elegant solution.
fooBandfooCshare a common ancestor that declaresfoo1andfoo2? - Idan Arye