Is this a function ?

This is a discussion on Is this a function ? within the C++ Programming forums, part of the General Programming Boards category; int fact (int n) { Is this a way a function starts in C++ ?...

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

    Is this a function ?

    int fact (int n) {

    Is this a way a function starts in C++ ?

  2. #2
    Registered User
    Join Date
    Feb 2008
    Posts
    36
    I meant to say

    Isnt Not :

    function fact (int n) {

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Functions in C or C++ are do not use a "function" keyword.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    36
    Ok

    So, It starts with what it returns type ?

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by kolucoms6 View Post
    Ok

    So, It starts with what it returns type ?
    Yes.

    [Technically, in standard C, you can omit the return type and it defaults to int - most modern compilers will issue a warning in this case, and it's considered bad style].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Feb 2008
    Posts
    36
    Cool.

    Understood.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM

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