Thread: Functions with variable argument count..

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    217

    Functions with variable argument count..

    I'm wondering if there is a way to deal with functions that can have a variable number of arguments passed to it. I already know of va_* functions but it doesn't seem that good. I was hoping there would be some way to restrict the data type to one data type, and also have random access to the arguments (va_* doesn't seem to have random access, unless you iterate through and copy it all to your own array first). It also seems that the va_* only works for basic data types and not my own class that i made.

    Something like this:

    Code:
    std::string FormatString(const std::string& format, int num, const Variable* varList, ...)
    {
    }
    Where "num" is the number of arguments passed and "varList" is an array of the arguments.

    EDIT: err...nvm about the example, but is there any other methods for variable functions arguments? Would you have to use asm or something?
    Last edited by 39ster; 04-11-2009 at 09:06 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Variable Array Size From Command Line Argument?
    By Cell in forum C Programming
    Replies: 6
    Last Post: 03-30-2009, 09:08 PM
  2. variable modification inside functions
    By point in forum C++ Programming
    Replies: 6
    Last Post: 06-17-2005, 08:36 PM
  3. variable argument lists
    By cProGrammer28 in forum C Programming
    Replies: 2
    Last Post: 05-03-2005, 06:27 AM
  4. Variable Argument Functions
    By genghis in forum C++ Programming
    Replies: 6
    Last Post: 02-10-2002, 02:01 PM
  5. Overloading functions with variable arguments
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 11-08-2001, 09:02 AM