How to pass optional arguments to a method in C++? -


how pass optional arguments method in c++ ? code snippet...

here example of passing mode optional parameter

void myfunc(int blah, int mode = 0) {  if(mode == 0)   do_something();  else   do_something_else(); } 

you can call myfunc in both ways , both valid

myfunc(10); //mode set default 0 myfunc(10, 1);//mode set 1 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -