Hi, can anyone help me ? i dunno how to solve this. Pls help.
Please follow the step to reach the Question.
Thanks a lot!!!
Code:
Step (1): Type structure definition
typedef struct menu_item_struct
{
ros_data_hdr_t data_hdr; /* place holder for ros header */
struct menu_item_struct *next_item; /* next menu item in the list */
UINT8 position; /* menu item position */
struct
{
uniChar_t uniString[1]; /* place holder for string of Unicode characters */
UINT8 asciiString[1]; /* place holder for string of ASCII characters */
} text;
} menu_item_t;
typedef struct
{
UINT8 row; /* start row for menu */
UINT8 max_item; /* largest menu item position */
menu_item_t *first_menu_item; /* pointer to the first menu item in the list */
} menu_item_list_t;
Step (2): Global variables declaration
menu_item_t * * m_menuitem;
UINT8 index=0;
Step (3):
void setMenuItems( UINT8 index, menu_item_t * menu_item )
{
m_menuitem[index] = menu_item;
}
//First, assume that the above "setMenuItems" was called for 5 times. Therefore, m_menuitem[] should have 5 elements now, and index has been incremented to 5.
Step (4):
//After that, assume that "process_menuItemfunc()" is called. At this point, m_menuitem[]contains 5 items.
void process_menuItemfunc()
{
//In this function, I have to call "putMenu(menuItem_t *menuItemPtr, uint8_t num_of_items)" as defined below.
//Notice that the 1st parameter of the "putMenu()" is a pointer to an array of menu items to be displayed.
//The menu item is of class "menuItem_t" as defined below.
//So, before I could call "putMenu", I have to populate the 1st parameters. Because the "m_menuitem" and "menuItem_t" are of different types.
//Therefore, I cannot pass in "m_menuitem" directly to "putMenu()" as its 1st parameter.
//QUESTION : How to populate/construct the 1st parameter, which is the pointer to an array of menu items of class menuItem_t?
}
//A class called menuItem_t is defined as below
class menuItem_t {
public:
UINT8 position;
UINT16 state;
UINT16 *uniString;
};
//*menuItemPtr - This is a pointer to an array of menu items to be displayed.
void putMenu (menuItem_t *menuItemPtr, UINT8 num_of_items)
{
//some processing here
}