1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

query Regarding Function in c++

Discussion in 'C++' started by charan, May 25, 2007.

  1. charan

    charan New Member

    Joined:
    May 13, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi ,

    I have two query regarding c++ function.In C,By default the default return type of a function is void and of main() is int.Do the same thing happens in c++,and
    Secondly ,can we in c++ define a function without declaring it earlier.means is function declaration mandatory in c++ or not.
    Hope i will get a response..
    Thanks
    Charan
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    The default return type of a function in C is not void, but int. The return type of main is int for both languages. Function declarations (or definitions prior to use) are mandatory in C++, which is a more strongly typed language.
     
  3. charan

    charan New Member

    Joined:
    May 13, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thanks Dawei.
     
  4. mandar

    mandar New Member

    Joined:
    May 25, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hello,
    The function declaration in C++ is always mandotory. and all the default function return types in c are integers. mind u those are not void.


    Regards.. Mandar
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    The function declaration is not mandatory in C++ if the fuction definition precedes the first use of the function.
     

Share This Page