|
-
Jun 2nd, 2000, 02:34 AM
#1
Thread Starter
Frenzied Member
can you use optional parameters in C++, like in VB
Code:
Function MyFunc(Optional Pram As Long = 10) As Long
how would I do that in C++ without overloading, I want to do this for a constructor so I can't call it from overloaded versions, and I have loads of optional params of the same type anyway so It'd make it hard to overload
-
Jun 3rd, 2000, 08:57 PM
#2
Monday Morning Lunatic
You can use the stdarg system. I'm not too sure how it works, but you basically define your function thus:
Code:
void myfunc(int arg_a, bool arg_b, ...) {
}
This means that arg_a and arg_b are compulsory (in the normal way), but other arguments can be added onto the end.
there is then a set of functions and macros to extract an array of parameters. Take printf for example - if you can get the source code to that you should be fine.
-
Jun 4th, 2000, 11:40 AM
#3
New Member
look up va_arg, va_start or va_end in the help files - MSVC has an example program there to help, I'd imagine *nix would have similar in their man pages.
Shab.
Code:
Print WeekDayName(vbMonday)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|