Thread: Overloading functions with variable arguments

  1. #1

    Overloading functions with variable arguments

    I have a function that accepts a variable argument list. I would like to extend this function by adding a new argument to the beginning and then calling the original function but I am having trouble with the declaration. Can anyone help?

    extern int OriginalFunction( int A, ... );

    int NewFunction( char *psz, int A, ... )
    // call original function
    OriginalFunction( A, ??? );

  2. #2
    Registered User
    Join Date
    Oct 2001
    how could someone else fill the ... for you???
    If You've Be Biten By DaRk$nAkE The Only Things You Will See R Bytes

  3. #3
    No I don't have access to the original code and I wouldn't want to break it. I would like to use the polymorphic abilities of C++.

    Is there no way to extend such a function without rewriting it or determining the number of arguments.

    I was hoping for a way to extend the functionality by decending from it. Something like:

    int NewFunction( char *psz, int A, ... ) : OriginalFunction( ??? )

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    inheritance doesn't work like that....

    to do that you would need to encapsulate your function in a class and make it virtual. Then inherit another class from that one and override the virtual function. This would still require you to rewrite the function or do some additional processing and then call the base class version.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Variable Arguments through Command Line
    By zombiezparadize in forum C Programming
    Replies: 5
    Last Post: 05-06-2008, 07:35 AM
  2. overloading for an arbitry number of arguments in a function
    By indigo0086 in forum C++ Programming
    Replies: 7
    Last Post: 01-25-2008, 09:26 AM
  3. Functions with a variable number of arguments
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2002, 01:12 AM
  4. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 02:26 PM
  5. (Variable Arguments,...)
    By Sebastiani in forum C Programming
    Replies: 3
    Last Post: 09-07-2001, 10:44 AM