Thread: Allocating functions to an array of function pointers inside a struct

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657

    Allocating functions to an array of function pointers inside a struct

    Suppose I have 10 functions.
    f0,f1.....f9 (all void x(void))
    and a
    void (*func)(void)[10] ; //this is inside a struct (or a c++ class )

    and there is another function
    void foo(object,int); // or object.foo(int) in c++

    How would I specify(with the minimum amount of code involved) that
    foo(object,n) should call *(func[n])() which is, in turn synonymous to a call to fn()
    ?

    [Do tell if a c++ based solution also works ]
    Last edited by manasij7479; 07-03-2011 at 01:14 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. array inside struct
    By tat in forum C Programming
    Replies: 15
    Last Post: 11-13-2007, 12:36 PM
  2. initializing char array inside a struct
    By panos in forum C Programming
    Replies: 6
    Last Post: 06-01-2007, 06:43 PM
  3. allocating array of pointers
    By l2u in forum C++ Programming
    Replies: 1
    Last Post: 06-01-2006, 10:11 AM
  4. Dynamicly allocating an array of pointers
    By kzar in forum C Programming
    Replies: 2
    Last Post: 05-05-2005, 04:50 PM
  5. Replies: 4
    Last Post: 09-12-2001, 02:05 PM