Optional parameters

Hi,

Does C++ have something like optional parameters? I've Googled it and it has a lot of results, but nothing that really answers how to use it in an easy example :S

Thanks
Can you elaborate? Perhaps state the problem you have that would need optional parameters?
I actually don't have an example. I know I've seen this in another language (I believe it was VB .NET) and it just came up in my mind.
The closest thing C++ has to optional parameters are:
- function overloading:
1
2
void func( int required );
void func( int required, int optional );


- default parameters:
 
void func( int required, int optional = 0 );


- variable argument lists:
 
void func( int required, ... );


Note the 3rd option is not typesafe and is a huge pain to work into code safely
Thank you Disch =)
Basically ellipsis is useless in C++ and should be avoided. Either of the first two ways is fine.

Topic archived. No new replies allowed.