when to use function pointer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunmib
    New Member
    • May 2007
    • 104

    when to use function pointer

    Hi all,
    I have a doubt can anybody give me some sort of thumb rule as when can I use function pointers and when not to...From my reading I am able to grasp only the following, What is a function pointer and for usage examples, it used in threading or passing functions as arguments to another function.
    Till date I cannot get a clear picture as why should I use it and when should I use it and when I should NOT us it.Can anybody shed some light on it...
  • svlsr2000
    Recognized Expert New Member
    • Feb 2007
    • 181

    #2
    Originally posted by arunmib
    Hi all,
    I have a doubt can anybody give me some sort of thumb rule as when can I use function pointers and when not to...From my reading I am able to grasp only the following, What is a function pointer and for usage examples, it used in threading or passing functions as arguments to another function.
    Till date I cannot get a clear picture as why should I use it and when should I use it and when I should NOT us it.Can anybody shed some light on it...
    There is no thumb rule as such in usage of function pointer. You can use function pointer, when you want to use call backs or thread execution. or when you are implementing state machine, ie when u want to call different functions when state of your process changes.

    Comment

    • fantasticamir
      New Member
      • Apr 2007
      • 42

      #3
      http://www.newty.de/fpt/index.html
      http://www.goingware.c om/tips/member-pointers.html

      hope it works for you!

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        The guideline is simple: Will you decide at run-time which function to call?

        If yes, use function pointers. If no, just call the function.

        Use of function pointers is the fundamental basis for object-oriented programming. These function pointers are managed by the compiler in a table produced when you declared the functions virtual.

        Comment

        • arunmib
          New Member
          • May 2007
          • 104

          #5
          thanks for the info guys....

          Comment

          Working...