Results 1 to 4 of 4

Thread: Function: ... Argument

  1. #1
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Wink Function: ... Argument

    Hello Friends,
    Could you please tell me what is the meaning of this parameter "..." and how to access the ... parameter? The sample code is given below:-
    Qt Code:
    1. #include <iostream>
    2. using namespace std;
    3. void foo(int x,...);
    4. int main()
    5. {
    6. foo(5);
    7. return 0;
    8. }
    9.  
    10. void foo(int x,...)
    11. {
    12. cout<<x;
    13. }
    To copy to clipboard, switch view to plain text mode 
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function: ... Argument

    Read about C functions va_start and va_arg

  3. The following user says thank you to Lesiok for this useful post:

    sonulohani (12th December 2012)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Function: ... Argument

    Functions of this type are called Variadic functions. It is a mechanism for specifying a variable number of arguments of unspecified type. Variadic functions are often a bad idea, not type safe for example, and have workable alternatives.

  5. The following user says thank you to ChrisW67 for this useful post:

    sonulohani (12th December 2012)

  6. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Function: ... Argument

    not to be confused with variadic templates in C++11!
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Invoking dll function with argument crashed
    By moiit in forum Qt Programming
    Replies: 13
    Last Post: 7th March 2012, 15:34
  2. onclick event passing argument to js function
    By dyngoman in forum Qt Programming
    Replies: 0
    Last Post: 10th September 2011, 14:51
  3. QVector as function argument
    By stefan in forum Qt Programming
    Replies: 4
    Last Post: 12th May 2011, 13:40
  4. QMap as function argument...
    By cydside in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2009, 18:59
  5. Replies: 1
    Last Post: 12th January 2009, 19:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.