Thread: why is this so?

  1. #1
    Registered User
    Join Date
    Aug 2007

    why is this so?

    in c if we use main();
    we donot get any error
    but in c++ we have to mention the return type
    can any one tell me why is this??

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    C (well the C89 version at least) permits implicit declarations, so if you omit the type then int is assumed. In C99 (the new standard for C), this is no longer allowed, and you have to say what you mean.

    C++ being more strongly typed than C from the outset never had the notion of implicit types.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed