why is this so?

This is a discussion on why is this so? within the C++ Programming forums, part of the General Programming Boards category; in c if we use main(); we donot get any error but in c++ we have to mention the return ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    34

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

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