Thread: Dynamic Function Pointer

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    162

    Dynamic Function Pointer

    Hi

    A quick question, how to allocate a dynamic array of function pointers? I am getting a syntax error when trying to. The following code might give a better understanding:

    Code:
    double func(const double); // function declaration
    
    double (**FuncPtr) (const double); // dynamic array
    
    FuncPtr = new double (*)(const double)[MAX]; // syntax error
    Last edited by Aidman; 08-29-2003 at 03:35 PM.
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    162
    Thanks a lot Salem! That not only fixed my problem but made my life easier
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    If you don't want to use typedef:
    Code:
    FuncPtr = new (double (*[100])(const double));
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    Registered User
    Join Date
    Dec 2002
    Posts
    162
    Thanks Sang-drax. By the way, very nice game you got there. I like the graphics.

    Are you using DX or regular win GDI?
    We haven't inherited Earth from our parents; instead we have borrowed her from our children - old Indian saying.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointer to function and dynamic allocation
    By cfdprogrammer in forum C Programming
    Replies: 7
    Last Post: 07-08-2009, 10:36 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Compiler "Warnings"
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 04-24-2005, 01:09 PM
  4. dynamic function execution
    By Sargnagel in forum C Programming
    Replies: 7
    Last Post: 05-07-2003, 05:28 AM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM