Say I have the following:
typedef struct {
int x;
int y;
char a;
char b;
} myStruct;
Is it better practice to create a new
Personally I often use aggregate initialisation for simple data objects:
struct MyStruct {
int x;
int y;
char a;
char b;
};
int main()
{
MyStruct s = {10, 20, 'e', 'u'};
}
Or hard coded defaults like this:
struct MyStruct {
int x;
int y;
char a;
char b;
};
const MyStruct MyDefault_A = {0, 0, 'a', 'z'};
const MyStruct MyDefault_B = {10, 20, 'e', 'u'};
int main()
{
MyStruct s = MyDefault_A;
}