Wednesday, January 6, 2010

OOP344 - Assignment 2 about void(*_help)(messageStatus,IO_Form)

Here I got response from other group member - Ausley Lettroy Johnson.
Thanks.
------------------------------------------------------------------------------
RESOPNSE TO QUESTIONS BY FELLOW STUDENTS
Note: void(*_help)(messageStatus,IO_Form)
The above “_help” is a pointer to a function or logic that are passed the two arguments.
You use it like the following way:
(_Help)(ClearMessage, (*_owner));
Note: “*_owner” is a pointer to a form which controls all the fields and the fact that everything is done on a particular form, you have to be able to refer to it.
Note:”ClearMessage” is a value withing the enum list which is declared in iodef.
Note: The function logic has to be defined so that it processes the information passed to it. In this case, it gives a help message or clears the printed message at a particular location on the form. Help message might be date must be between a particular time.
Bool (*_Validate)((char*)_data.(*_owner));
Like help, this points to a logic that validates an entry. You also have to define the logic. What ever you want to validate that your form receives. The date etc.
You call it like above “_help” passing an address to the data entered and the form that is being used.

Question was: Do you initialize the pointer to the function logic? Yes
How:
bool (*Validate)(const char* , IO_Form&) = ((void(*)(MessageStatus, IO_Form&))(0))
Note: NO_FUNC is defined in iodef which initializes the “*Validate”
So you simply do within the class declaration
bool (*Validate)(const char* , IO_Form&) = NO_FUNC;
REMEMBER to include iodef.h.
Qusetion: How to use IO_Vedit display?
Ans: Since vedit inherits edit, you simply call the display of edit which is the working class. Vedit is simply for validation and for help messages. Therefore the arguments passed to vedit constructor must be passed onto edit and when you are requested to edit you do the following:
IO_Edit::edit();//The display code is within this function which makes editing possible.
Note: The pointer to data in iofield does not need dynamic memory allocation from within that class. It simply holds the address for location already allocated memory within ioedit. Therefor “IO_Field::_data = data.”


Hope it helps.

No comments:

Post a Comment