Generic pointer to member functions of a class

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

This topic contains 3 replies, has 2 voices, and was last updated by  shalizy 9 years, 10 months ago.

  • Author
    Posts
  • #2057

    Tanishq
    Member

    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
    Member

    Offcourse man!!!

    Asadullah Ansari

  • #3315

    Tanishq
    Member

    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
    Member

    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…

You must be logged in to reply to this topic.

0 Shares
Share
+1
Tweet
Share
Stumble