3 ms·
This would be a case where C99 style designated initializers would come in handy in C++. For example if you have a struct like: struct data { double w
by tbirdz 11y ago
This would be a case where C99 style designated initializers would come in handy in C++.
For example if you have a struct like:
struct data {
double w;
double x;
double y;
double z;
};
You can then create a struct of that type using syntax like:
struct data d = {.w = 1.0, .x = 1.0, .y = 1.0, .z = 1.0};
Then you could have your functions take a struct data as a parameter, and use designated initializers to have syntax for keyword parameters.
I'm not sure why this feature never made its way into a C++ standard over the years.
- J_Darnley 11y agoDon't forget that you can also have functions return a struct.