0

I have a function define in header file as this:

int myfunction(VpTR*& viewporttable,  wchar* vpname=L"*Active", OpenMode f=fR);

how i can call this function but ignore second argument? I tried calling it with the following code but an error message appeared: expected an expression

myfunction(myviewporttable,, fR);

can i omit this argument but it still understands L "* Active" as the called value?

Nguyen Manh
  • 73
  • 1
  • 6

1 Answers1

0

The syntax doesn't allow to omit parameter values at arbitrary positions, only those at the very end of the list.

You have to overload 2 versions:

int myfunction(VpTR*& viewporttable,  OpenMode f=fR) {
    return myfunction(viewporttable,L"*Active",L"*Active",f);
}

int myfunction(VpTR*& viewporttable,  wchar* vpname=L"*Active", OpenMode f=fR);

Then you can call

myfunction(myviewporttable, fR);
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190