I have thread spawning function which accepts many parameters which have default values in the declaration.
int spawn( funcptr func, void arg = 0,int grp_id = 1,const charthreadname);
I want to initialize first parameter func and the last parameter thread name and remaining variables assigned their default values.
spawn( myfunc,"My Thread");
How can I do this.
You can't.
Other languages support things like spawn(myfunc, , , "MyThread")
, but not C++.
Instead, just overload it to your liking:
inline int spawn( funcptr func, const char*threadname) {
return spawn(func, 0, 1, threadname);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With