Syntax problems
-
void ObjectRoot::runUpdateHandlers( ObjectRootPtr obj, const RTI::AttributeHandleValuePairSet& theAttributes ) { if (obj) { for (unsigned int i=0; i < ObjectRoot::ms_numUpdateHandlers; i++) { if (ObjectRoot::ms_updateHandlers[i]) {
(*ms_updateHandlers[i])(obj, theAttributes);
} } } } I don't understand what the code highlighted in brown does....... I am a beginner... please help me out Thanks -
void ObjectRoot::runUpdateHandlers( ObjectRootPtr obj, const RTI::AttributeHandleValuePairSet& theAttributes ) { if (obj) { for (unsigned int i=0; i < ObjectRoot::ms_numUpdateHandlers; i++) { if (ObjectRoot::ms_updateHandlers[i]) {
(*ms_updateHandlers[i])(obj, theAttributes);
} } } } I don't understand what the code highlighted in brown does....... I am a beginner... please help me out Thanksms_updateHandlers is a function pointer array, e.g. an array of pointers that point on functions. (*ms_updateHandlers[i]) points on function number i in the array. (obj, theAttributes) are the parameters of the function. So (*ms_updateHandlers[i])(obj, theAttributes); is a function call of function number i in the ms_updateHandlers array, with parameters obj and the Attributes.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
-
ms_updateHandlers is a function pointer array, e.g. an array of pointers that point on functions. (*ms_updateHandlers[i]) points on function number i in the array. (obj, theAttributes) are the parameters of the function. So (*ms_updateHandlers[i])(obj, theAttributes); is a function call of function number i in the ms_updateHandlers array, with parameters obj and the Attributes.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Hey Rage, thanks for the reply What if you had a situation where you had two functions of the same parameters (obj, theAttributes). How does the pointer know which function to point to?
Rage wrote:
(*ms_updateHandlers[i]) points on function number i in the array.
I thought ms_updateHandlers is an array of pointers therefore i is a pointer number Thanks
-
Hey Rage, thanks for the reply What if you had a situation where you had two functions of the same parameters (obj, theAttributes). How does the pointer know which function to point to?
Rage wrote:
(*ms_updateHandlers[i]) points on function number i in the array.
I thought ms_updateHandlers is an array of pointers therefore i is a pointer number Thanks
-
Hey Rage, thanks for the reply What if you had a situation where you had two functions of the same parameters (obj, theAttributes). How does the pointer know which function to point to?
Rage wrote:
(*ms_updateHandlers[i]) points on function number i in the array.
I thought ms_updateHandlers is an array of pointers therefore i is a pointer number Thanks