Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Syntax problems

Syntax problems

Scheduled Pinned Locked Moved C / C++ / MFC
helplearning
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jay03
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • J Jay03

      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

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      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

      J 1 Reply Last reply
      0
      • R Rage

        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

        J Offline
        J Offline
        Jay03
        wrote on last edited by
        #3

        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

        L H 2 Replies Last reply
        0
        • J Jay03

          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

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Jay03 wrote:

          How does the pointer know which function to point to?

          http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=140&rl=1[^]

          led mike

          1 Reply Last reply
          0
          • J Jay03

            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

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            See A TUTORIAL ON POINTERS AND ARRAYS IN C [^] maybe it is some helpful to you

            _**


            **_

            WhiteSky


            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups