Function ?

This is a discussion on Function ? within the C++ Programming forums, part of the General Programming Boards category; Hey All ! OK the standard format for defining a function: Code: typeName functionName(parameterList) { statements return value; // value ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    25

    Question Function ?

    Hey All !

    OK the standard format for defining a function:
    Code:
    typeName functionName(parameterList)
    {
          statements
          return value;   // value is of type typename
    }
    would this also be legal for defining a function?
    Code:
    typeName functionName(int a, int b)
    {
          return (a + b);   /* define the arguments here for use 
                                        let's say by a main function that 
                                        the user input a & b  */
    }
    Last edited by teeyester; 08-22-2003 at 12:01 PM.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Yes that's fine.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    25

    Thumbs up

    Thanks Mr Wizard..........

  4. #4
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Of course you could have simply compiled the code. I guess the compiler would have complained if it was not valid =)

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    25

    Thumbs up

    darksaidin :
    Touche : Your right...would have learned more that way ........Teeyester

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, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  4. Replies: 28
    Last Post: 07-17-2006, 12:35 AM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 07:44 PM

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