classes with optional parameters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how to writes classes or functions with optional parameters in c++ ?
 
You must specify the default value in the function (constructor) prototype
defined in the header file, e.g.

// In header file:
...
int DoSomething(int nRequired, int nOptional = 0);
...

// In source file:
int MyClass::DoSomething(int nRequired, int nOptional)
{
...
}

All optional parameters must be at the end.

Alek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top