Problems with constructors in nested structs and unions
I have a struct nested within a class and a union of that struct. If I have a struct constructor that takes arguments, then the union won't compile.
I also want to create an instance of the struct using an argument. That line also fails.
Also if I try to create an instance using braces to initialise it fails.
class test
{
public:
test(void);
~test(void);
struct dtType {
// inline constructors with initialisation lists
dtType() : mins(0), hrs(0),day(0),mnth(0),year(0),DPOffset(0),DTType(0) {}
dtType(byte z) : mins(z), hrs(z),day(z),mnth(z),year(z),DPOffset(0),DTType(0) {}
dtType(byte n,byte h, byte d, byte m, byte y, byte o, byte t) : mins(n), hrs(h),day(d),mnth(m),year(y),DPOffset(o),DTType(t) {}
// if I comment out the union it compiles, otherwise I get:
// error C2620: member 'test::dtUnion::dt' of union 'test::dtUnion' has user-defined constructor or non-trivial default constructor
union dtUnion {
dtType dt;
unsigned long dtLong; // 32 bits
} dtU;
Bookmarks