Home Forums C Programming Generic pointer to member functions of a class

Viewing 3 reply threads
  • Author
    Posts
    • #2057
      Tanishq
      Participant

      Hello Folks!!!!
      i have one interesting question over here ……….
      Is it possible to create a generic pointer (generic pointer to member functions) which can point to all the member functions of a class
      Ex : Code: ( cpp )

      here a generic pointer which can hold the address of functions fun1 as well as fun2
      Comments will be appreciated.!!!!

    • #3314
      shalizy
      Participant

      Offcourse man!!!

      Asadullah Ansari

    • #3315
      Tanishq
      Participant

      Assalmaulaikum Asad, This is not wot i wanted… i wanted to have a pointer to a member function and not a pointer to object….
      Ex: int (abc:: *ptr)(int );here ptr is an pointer to a member function of the class…
      something like this which is very generic and can hold the address of every function of that class..

    • #3316
      shalizy
      Participant

      walakum salam nadeem bhai!!!

      Now  you give correct requirement!!!  
      we can declare a pointer to anf member functions which has any number and any type of arguments. But return type will be same .

      I did’nt try to take return type as as  template. I dont template will woek or not…

Viewing 3 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.