struct constructor initialization c++ code example
Example 1: c++ struct constructor
struct TestStruct {
int id;
TestStruct() : id(42)
{
}
};
Example 2: c++ initialize a struct
struct address {
int street_no;
char *street_name;
char *city;
char *prov;
char *postal_code;
};
address temp_address = {
0, // street_no
nullptr, // street_name
"Hamilton", // city
"Ontario", // prov
nullptr, // postal_code
};