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. Object Definition

Object Definition

Scheduled Pinned Locked Moved C / C++ / MFC
question
10 Posts 6 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

    typedef UpdateHandler* UpdateHandlerPtr; I saw this code in a project file but I couldn't find what the definition of UpdateHandler is. It is not defined anywhere. Only thing I found on UpdateHandler is the code below What does the syntax below do? typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

    Z B 2 Replies Last reply
    0
    • J Jay03

      typedef UpdateHandler* UpdateHandlerPtr; I saw this code in a project file but I couldn't find what the definition of UpdateHandler is. It is not defined anywhere. Only thing I found on UpdateHandler is the code below What does the syntax below do? typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

      Z Offline
      Z Offline
      Zac Howland
      wrote on last edited by
      #2

      Jay03 wrote:

      typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

      That is the definition of UpdateHandler. This syntax is creating a function pointer. For more information, look up callback functions and function pointers.

      If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

      J J 2 Replies Last reply
      0
      • Z Zac Howland

        Jay03 wrote:

        typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

        That is the definition of UpdateHandler. This syntax is creating a function pointer. For more information, look up callback functions and function pointers.

        If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

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

        Isn't it a declaration? It's interesting - I wonder how the compiler parsed out the fact that it is not typedef'ing void?


        A cynic is a man who, when he smells flowers, looks around for a coffin.
        -H.L. Mencken

        S 1 Reply Last reply
        0
        • J JWood

          Isn't it a declaration? It's interesting - I wonder how the compiler parsed out the fact that it is not typedef'ing void?


          A cynic is a man who, when he smells flowers, looks around for a coffin.
          -H.L. Mencken

          S Offline
          S Offline
          SimonSays
          wrote on last edited by
          #4

          The problem is that function pointer syntax is bizarre (sorry guys it is). In this example you are typdefing a function pointer that returns void and two parameters (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&) to the name UpdateHandler. It does look wierd, but it works. On those occasions I need function pointers, I always have to look at an example because I can never quite remember it.

          J P 2 Replies Last reply
          0
          • J Jay03

            typedef UpdateHandler* UpdateHandlerPtr; I saw this code in a project file but I couldn't find what the definition of UpdateHandler is. It is not defined anywhere. Only thing I found on UpdateHandler is the code below What does the syntax below do? typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

            B Offline
            B Offline
            Bram van Kampen
            wrote on last edited by
            #5

            I Suggest you read the Book by Brian W. Kernighan & Dennis M. Ricthie: the C Programming Language This book is Much maligned, but actually very good! It spells out the Syntax and methods of the C Language, without going into the legalities, like the ANSI standard does! On page 122 of my copy it gives paragraph 5.12- Complicated Declarations. It explains there in lucid details how to read your declaration, and gives the code for a simple program which takes a declaration, and translates it back into 'english' Success

            LateNightsInNewry

            1 Reply Last reply
            0
            • S SimonSays

              The problem is that function pointer syntax is bizarre (sorry guys it is). In this example you are typdefing a function pointer that returns void and two parameters (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&) to the name UpdateHandler. It does look wierd, but it works. On those occasions I need function pointers, I always have to look at an example because I can never quite remember it.

              J Offline
              J Offline
              JWood
              wrote on last edited by
              #6

              And it's going to show up on one of the awful employment tests that they give us.


              A cynic is a man who, when he smells flowers, looks around for a coffin.
              -H.L. Mencken

              Z 1 Reply Last reply
              0
              • S SimonSays

                The problem is that function pointer syntax is bizarre (sorry guys it is). In this example you are typdefing a function pointer that returns void and two parameters (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&) to the name UpdateHandler. It does look wierd, but it works. On those occasions I need function pointers, I always have to look at an example because I can never quite remember it.

                P Offline
                P Offline
                Prakash Nadar
                wrote on last edited by
                #7

                Thanks, This brought some clarity on function pointer to me and i think this is a better of doing it. I hope this method is supported in most all compilers. typedef int FunctPtr(int,int); .... main { FunctPtr *fp = somefunction; //This declaration is clearer that fp variable is a pointer. fp(...); } typedef int (*FuctPtr1)(int, int); //sometimes looks confusing as what is happening. and FuctPtr1 c = somefunc; -- modified at 4:03 Thursday 17th August, 2006 -- modified at 4:04 Thursday 17th August, 2006


                -Prakash

                1 Reply Last reply
                0
                • J JWood

                  And it's going to show up on one of the awful employment tests that they give us.


                  A cynic is a man who, when he smells flowers, looks around for a coffin.
                  -H.L. Mencken

                  Z Offline
                  Z Offline
                  Zac Howland
                  wrote on last edited by
                  #8

                  From experience, I can tell you that it will if you ever apply to Amazon.com. Just an FYI.

                  If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

                  1 Reply Last reply
                  0
                  • Z Zac Howland

                    Jay03 wrote:

                    typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

                    That is the definition of UpdateHandler. This syntax is creating a function pointer. For more information, look up callback functions and function pointers.

                    If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

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

                    Zac Howland wrote:

                    This syntax is creating a function pointer

                    Won't it be typedef void UpdateHandlerPtr (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&); or typedef void (UpdateHandler*) (ObjectRootPtr,const RTI::AttributeHandleValuePairSet&);

                    Z 1 Reply Last reply
                    0
                    • J Jay03

                      Zac Howland wrote:

                      This syntax is creating a function pointer

                      Won't it be typedef void UpdateHandlerPtr (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&); or typedef void (UpdateHandler*) (ObjectRootPtr,const RTI::AttributeHandleValuePairSet&);

                      Z Offline
                      Z Offline
                      Zac Howland
                      wrote on last edited by
                      #10

                      typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&); is syntaxically equivalent to writing typedef void (*UpdateHandlerPtr)(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

                      If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

                      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