I have 2 structures in which 90% of their fields are the same. I want to group these fields in a structure, but I do not want to use the point operator to access them. The reason is that I am already encoded with the first structure and just created the second.
before:
typedef struct{
int a;
int b;
int c;
object1 name;
} str1;
typedef struct{
int a;
int b;
int c;
object2 name;
} str2;
Now I would create a third structure:
typedef struct{
int a;
int b;
int c;
} str3;
and change str1 and atr2 to this:
typedef struct{
str3 str;
object1 name;
} str1;
typedef struct {
str3 str;
object2 name;
} str2;
Finally, I would like to have access to a, b and c by doing:
str1 myStruct;
myStruct.a;
myStruct.b;
myStruct.c;
and not:
myStruct.str.a;
myStruct.str.b;
myStruct.str.c;
Is there any way to do this. The reason for this is because I want to save integrety from the data if there were changes in the structure and not repeat myself and change my existing code and not have too deeply nested fields.
RESOLVED: . , , :
struct str11
{
int a;
int b;
int c;
};
typedef struct str22 : public str11
{
QString name;
}hi;