Thread: which one are declarations and which one are definitions

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    4

    which one are declarations and which one are definitions

    Assume these statements are all outside of functions. Which of the following are declarations only and which are definitions:
    float * rate ;
    struct S ;
    static double pi;
    typedef int * string;
    node * fun(int i);
    extern double x;

    --------------------

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Let me google that for you.

    Try to do your own homework (did you read the site's homework policy?). Tell us which you think are definitions and which are declarations, and why, and we will help you where you went wrong.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    typedef int * string;
    node * fun(int i);

    are the only definition i can think off.

    Others are declarations.
    Last edited by xanli; 03-18-2011 at 11:05 AM.

  4. #4
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    You failed to answer the "why" part, the part I put in bold in my post, because it's extremely important. Why do you think those two are the only definitions?

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    I don't know what struct S ; does. If anything.

Popular pages Recent additions subscribe to a feed