Results 1 to 4 of 4

Thread: Function with a variable number of arguments

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Function with a variable number of arguments

    I wonder if it is possible to retrieve the number of arguments of a function variable in C++. It is necessarily, otherwise how would the class std:: vector with its methods assign () and resize ().

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Function with a variable number of arguments

    When a function is declared, the data-type and number of the passed arguments are usually fixed at compile time. The general format for declaring the function remains the same as before except the data type passed as arguments in functions are in the same order in which it is defined in function.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Function with a variable number of arguments

    These are default settings, for example:
    Code:
    	  void function (int x = 1, int y = 0);

    () function will call the function with parameters (1.0) and function (10) with (10, 0).

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Function with a variable number of arguments

    To use a function with variable number of arguments, or more precisely, a function without a set number of arguments, you would use the cstdarg header file. C++ Variable argument functions are useful wherever we are not sure about the number of parameters to be passed. Not all the compilers have the ability to decipher variable arguments.

Similar Threads

  1. Passing arguments to a function
    By Aman 1 in forum Software Development
    Replies: 3
    Last Post: 09-12-2009, 01:11 PM
  2. Accessing a variable outside a function without arg
    By BoanHed in forum Software Development
    Replies: 3
    Last Post: 04-12-2009, 01:35 PM
  3. Variable method arguments in Csharp
    By KAMANA in forum Software Development
    Replies: 3
    Last Post: 14-11-2009, 05:57 PM
  4. How to Call a variable subroutine or function
    By Sayam in forum Software Development
    Replies: 2
    Last Post: 16-04-2009, 09:33 PM
  5. Calling a function with arguments or parameter in Powershell?
    By ArunJ in forum Software Development
    Replies: 4
    Last Post: 18-02-2009, 05:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,565,893.55387 seconds with 17 queries