Functions of arbitrary parameters

This is a discussion on Functions of arbitrary parameters within the C Programming forums, part of the General Programming Boards category; While browsing a c++ faq I came across this comparison with C and found something I either didn't know or ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    55

    Functions of arbitrary parameters

    While browsing a c++ faq I came across this comparison with C and found something I either didn't know or am reading wrong.
    Code:
    [6.11] Is C++ backward compatible with ANSI/ISO C?
    
    Almost.
    
    C++ is as close as possible to compatible with C, but no closer. In practice, the major difference is that C++ requires prototypes, and that f() declares a function that takes no parameters (in C, a function declared using f() can be passed an arbitrary number of parameters of arbitrary types).
    Is this saying that defining a function as something like

    Code:
    void f(); 
    
    /*...*/
    
    void f(){
    /*...*/
    }
    would let one do something like

    Code:
    f(45, 100);
    or

    Code:
    f("string", NUM, 2);
    or whatever? If so how do you refer to each argument in the function?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,129
    You are thinking of variable argument lists, but here that FAQ is talking about the number and types of parameters being unspecified in the declaration (but they may be specified in the definition).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    55
    Oh I see. Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Functions &passing parameters by reference
    By Labmouse in forum C++ Programming
    Replies: 6
    Last Post: 12-08-2007, 09:29 AM
  2. Inline functions and inheritance
    By hpy_gilmore8 in forum C++ Programming
    Replies: 3
    Last Post: 01-14-2004, 06:46 PM
  3. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  4. pointers, functions, parameters
    By sballew in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 10:33 PM

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