P
Pep
I have this massive legacy application to support and although it is
C++, it has been mostly written like a C application, making extensive
uses of structs instead of classes, which are recorded for persistence
in a database as a straight binary write.
So in order to supply a better way of handling a complex data field in
one of the structs, I have created another struct which is included
inside the original struct and things are working fine.
However my problem is that the new struct needs to have a member that
takes a parameter of the same struct and at that point C++ is
complaining.
The struct looks like this
typedef struct
{
private:
int field1;
int field2;
public:
setField1(int foo)
{
field1 = foo;
}
setField2(int foo)
{
field1 = foo;
}
setFields(myStruct& foo)
{
setField1(foo.field1);
setField2(foo.field2);
}
} myStruct;
However g++ complains that I am using a undeclared type in the
setFields method.
I have tried declaring it as setFields(struct myStruct& foo) and have
tried a forward declaration of struct myStruct before the struct
definition but none of these approaches work.
I do not want to use a void* ptr in the setFields method, is there any
way to do what I want to do?
TIA,
Pep.
C++, it has been mostly written like a C application, making extensive
uses of structs instead of classes, which are recorded for persistence
in a database as a straight binary write.
So in order to supply a better way of handling a complex data field in
one of the structs, I have created another struct which is included
inside the original struct and things are working fine.
However my problem is that the new struct needs to have a member that
takes a parameter of the same struct and at that point C++ is
complaining.
The struct looks like this
typedef struct
{
private:
int field1;
int field2;
public:
setField1(int foo)
{
field1 = foo;
}
setField2(int foo)
{
field1 = foo;
}
setFields(myStruct& foo)
{
setField1(foo.field1);
setField2(foo.field2);
}
} myStruct;
However g++ complains that I am using a undeclared type in the
setFields method.
I have tried declaring it as setFields(struct myStruct& foo) and have
tried a forward declaration of struct myStruct before the struct
definition but none of these approaches work.
I do not want to use a void* ptr in the setFields method, is there any
way to do what I want to do?
TIA,
Pep.