Hi,
How do i declare and use a function in c++ with variable number of
arguments...
Help
sandX 7 1440
"sandSpiderX" <m7*********@gmail.com> writes: Hi, How do i declare and use a function in c++ with variable number of arguments...
One way is to read up about "Default Arguments in C++ Functions",
but that might not solve all your problems.
Tim Love wrote: "sandSpiderX" <m7*********@gmail.com> writes:
Hi, How do i declare and use a function in c++ with variable number of arguments...
i dont know any special ways in C++, but varargs are one way to do (in
C) and i believe its portable too
do u mean this:
int main(int argc, _TCHAR* argv[])
{
.....
or do u want to call a function like this:
int bum(int x, char g, string pop)
{
....
bumb(0, "", "only here")
or woot?
sandSpiderX wrote: Hi, How do i declare and use a function in c++ with variable number of arguments...
Don't, find a better way! This hangover from C looses all of the type
safety provided by C++
Ian
"sandSpiderX" <m7*********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com... Hi, How do i declare and use a function in c++ with variable number of arguments...
If the arguments have the same type, you could pass the arguments in
a vector or list or something of that sort. Otherwise, stick to Ian's
advice.
--
jb
(reply address in rot13, unscramble first)
An another solution is a string. write all parameters to a string,
like "x=10,name=ashu,y=20.05" and parse this string inside the
function.
upashu2 wrote: An another solution is a string. write all parameters to a string, like "x=10,name=ashu,y=20.05" and parse this string inside the function.
Surely a map of strings with your favourite key type would be more flexible, easier, faster, than that?
Ben
--
I'm not just a number. To many, I'm known as a String... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Suzanne Vogel |
last post by:
'stdarg.h' defines the 'va_arg' type to use in passing variable numbers
of parameters to functions. The example of its use given in the
Dinkumware documentation *seems* to imply that the 'va_arg'...
|
by: Kapt. Boogschutter |
last post by:
I'm trying to create a function that has at least 1 Argument but can also
contain any number of Arguments (except 0 because my function would have no
meaning for 0 argument).
The arguments...
|
by: |
last post by:
How to call a function with variable argument list from another function
again with variable argument list?
Example :
double average ( int num, ... );
double AFunct1 ( int num, ... );
double...
|
by: The Directive |
last post by:
I read the C FAQ question on passing a variable number of arguments,
but it didn't help. The example assumes all arguments are of the same
type.
I want to create a function "trace" that can be...
|
by: Sathyaish |
last post by:
I knew this but I have forgotten. How do you declare a function that
has to accept a variable number of arguments?
For instance, the printf() function has a variable number of arguments
it can...
|
by: Russ Chinoy |
last post by:
Hi,
This may be a totally newbie question, but I'm stumped.
If I have a function such as:
function DoSomething(strVarName) {
.....
}
|
by: prasanthag |
last post by:
Hi,
I am a newbie to this group. I have a problem in handling the variable
arguments passed to a function. My requirement is like this.
I have 2 functions say,
void funcX(int i, int j);...
|
by: carvalho.miguel |
last post by:
hello,
imagine you have a static class method that receives a function
pointer, an int with the number of arguments and a variable number of
arguments.
in that static method you want to call...
|
by: CptDondo |
last post by:
How do you declare a function with 0 or mroe arguments?
I have a bunch of functions like this:
void tc_cm(int row, int col);
void tc_do(void);
void tc_DO(int ln);
and I am trying to ...
|
by: Alan |
last post by:
I have a couple of questions about using a variable number of
arguments in a function call (...). The context is that I have some
mathematical functions I created. I currently pass them a pair of...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |