RunTime polymorphism

creating Pointer to a class inside its own member function to achieve polymorphism. Below is an example.


class CmdParser_c
{
public:

CmdParser_c(){}
virtual ~CmdParser_c(){}

BOOLEAN ParseInputCmd(UINT8*);
virtual BOOLEAN ProcessInputCmd(UINT8* );
virtual BOOLEAN ProcessInputCmdArgs(UINT8* cmdList_ptr, UINT8 noOfArgs);
}


//One of its member function definition:

BOOLEAN CmdParser_c::ParseInputCmd(UINT8* cmdBuff_ptr)
{
CmdParser_c *tstObj[MAX_PARSERS]; // <-- creating array of base cls ptr

RTCcmdParser_c rtcTstObj;
UiParser_c uiP;

tstObj[0] = &rtcTstObj; // <-- assigning child1 cls obj
tstObj[1] = &uiP; // <-- assigning child2 cls obj

if (tstObj[0]->ProcessInputCmd(&inputCmd_ptr[0][0]))
{
//do something
} else if (tstObj[1]->ProcessInputCmd(&inputCmd_ptr[0][0]))
{
//do something
}
}

My code is working. No issues with that. My question is: is there any flaw in the way i created the array of ptr to a class inside its own member function to achieve runtime polymorphism? Anything wrong with this logically?
Topic archived. No new replies allowed.