I have an easy idea, here's how:
Create the structure as usual and create a simple function that initializes it:
struct Foo{...}; void Default(Foo &obj) {
If you have several structures, in C ++ you are allowed to overload the function, so you can have many functions called "default", each of which initializes its own type, for example:
struct Foo {
The C ++ compiler will know when to call the first or second overload based on this parameter. It makes a reference to any parameter that you give it, so any changes made to obj will be reflected in the variable that you put as the parameter.
Edit: I also have an idea how to specify some parameters, you can do this using the default parameters. Here's how it works:
For example, you use the following function; You can specify default values ββfor such parameters:
void Default (Foo &obj, int number_of_something = 0, int some_other_param = 10) { ... }
source share