Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:46:04+00:00 2026-05-16T14:46:04+00:00

Which disadvantages could I have if I want to use the function foo(int num,

  • 0

Which disadvantages could I have if I want to use the function

foo(int num, ...)

to implement the variable number of arguments?

I do know the first disadvantage that you can only use one data type.

Is there any way else to do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:46:05+00:00Added an answer on May 16, 2026 at 2:46 pm

    There are multiple ways NOT to use ellipsis notation.

    Why ? Because of type safety a hazardous manipulations of the primitives (va_start, va_arg, va_next) that you can’t really forward to another function etc…

    However, contrary to C, C++ provides template methods, which offer type safety and generic behavior, and this can be cumulated with overloads:

    template <typename Arg0>
    void foo(int num, Arg0 const& arg0);
    
    template <typename Arg0, typename Arg1>
    void foo(int num, Arg0 const& arg0, Arg1 const& arg1);
    
    // ... etc
    

    This is the current state of the art, which is generally helped by a subtle application of Preprocessor Programming (check out Boost.Preprocessor).

    With the new C++0x standard, come the variadic templates, which offer the same facilities than the C variadic methods, with type safety offered (yeeha)

    template <typename Arg0, typename... Args>
    void foo(Arg0 arg0, Args... args)
    {
      // Do something with arg0
      foo(args);
    }
    
    template <typename Arg0>
    void foo(Arg0 arg0)
    {
      // Do something with arg0
    }
    

    This also allows to define tuple classes much more easily 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which is better? Or use and OR mapper with SP's? If you have a
I have a class called ItemBase from which a number of classes inherit. In
I have an app which I want to run on as many Android phones
Which of the following has the best performance? I have seen method two implemented
Supposing my table has 10 columns .... which columns i have to choose to
Which graduate program should I choose – SUNY Buffalo or SUNY Binghamton?
Which Database table Schema is more efficient and why? Users (UserID, UserName, CompamyId) Companies
Which class design is better and why? public class User { public String UserName;
Which C#/.NET Dependency Injection frameworks are worth looking into? And what can you say
Which way do you prefer to create your forms in MVC? <% Html.Form() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.