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. Function pointer wooes

Function pointer wooes

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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.
  • A Offline
    A Offline
    aldeba
    wrote on last edited by
    #1

    How do i make a pointer to point to a function. and i hope to have this pointer to be able to point to several type of functions? like CString getDate(); CString getMonth(int i); how can make a pointer to point either to these two functions?? thanxs in advance

    T C R 3 Replies Last reply
    0
    • A aldeba

      How do i make a pointer to point to a function. and i hope to have this pointer to be able to point to several type of functions? like CString getDate(); CString getMonth(int i); how can make a pointer to point either to these two functions?? thanxs in advance

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      aldeba wrote: how can make a pointer to point either to these two functions?? You can't. The signatures of functions are different - getDate doesn't have arguments, while getMonth takes one integer argument. Why would you like to have one pointer which can point to either of these functions? Tomasz Sowinski -- http://www.shooltz.com

      What is "scratch" and why can everything be made from it?

      1 Reply Last reply
      0
      • A aldeba

        How do i make a pointer to point to a function. and i hope to have this pointer to be able to point to several type of functions? like CString getDate(); CString getMonth(int i); how can make a pointer to point either to these two functions?? thanxs in advance

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #3

        you can use a void * pointer to point at either function: void *p = getDate; p = getMonth; -c


        WWJD? JWRTFM.
           found on /.

        image effects!

        1 Reply Last reply
        0
        • A aldeba

          How do i make a pointer to point to a function. and i hope to have this pointer to be able to point to several type of functions? like CString getDate(); CString getMonth(int i); how can make a pointer to point either to these two functions?? thanxs in advance

          R Offline
          R Offline
          Renjith Ramachandran
          wrote on last edited by
          #4

          just tak ein to a void pointer .after that cast them in to appropriate funtion type.. Renjith-CPian.

          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