Thread: Confusion with typedef

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    21

    Arrow Confusion with typedef

    Code:
    typedef int (*test) ( float * , float*)
    test tmp;
    what is the type of tmp, is it int ?

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    No. Read up on function pointers.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    290
    Code:
    typedef int (*(*f)(int (*)(int)))(int (*)(int));
    Ruh roh, Shaggy!!

  4. #4
    abyss - deep C
    Join Date
    Oct 2007
    Posts
    46
    Quote Originally Posted by capvirgo View Post
    Code:
    typedef int (*test) ( float * , float*)
    test tmp;
    what is the type of tmp, is it int ?
    No, the type of tmp is the one which precedes it, 'test' in this case.

    the typedef statement defines an alias for an already existing datatype or to create a new user defined datatype.
    Code:
    eg:
    typedef int ud_int;
    ud_int var1;
    Here, ud_int is a user defined datatype which is similar to int.

    On the same lines,
    Code:
    typedef int (*test) ( float * , float*)
    'test' is the new datatype which you have defined and 'test' happens to be a pointer to a function which accepts two arguments of type float and returns an integer.

    Check this link below for more details on function pointers.
    http://www.newty.de/fpt/intro.html

    cheers
    maverix

  5. #5
    Registered User
    Join Date
    Feb 2008
    Posts
    21
    Thanks maverix

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 09:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 07:35 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 12:54 PM