typedef a function pointer question..

This is a discussion on typedef a function pointer question.. within the C++ Programming forums, part of the General Programming Boards category; Code: typedef void (*fp)(int i, int j); void typedef_func(int i, int j) { cout << "i = " << i ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    47

    typedef a function pointer question..

    Code:
    typedef void (*fp)(int i, int j);
    
    void typedef_func(int i, int j)
    {
    	cout << "i = " << i << " : j + " << j << endl;
    }
    
    int main()
    {
    	fp obj;
    	obj(5,6);
    
    	return 0;
    }
    from my understanding the above should work. but i can't seem to get it to work. please help out ..

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,304
    Your function pointer named obj was not initialised to point to typedef_func.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    47
    AAAAAAHhhhhhhhhh
    silly me.. learnt something new.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 07:54 PM
  2. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Typedef representing pointer to function
    By pdc in forum C Programming
    Replies: 3
    Last Post: 06-10-2005, 11:10 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21