G
Grumble
Hello all,
I came across the following definition (or is it declaration? I
never know):
struct OFFSET_AND_SIZE
{
INT64 offset;
UINT64 size;
OFFSET_AND_SIZE (INT64 o, UINT64 s) : offset (o), size (s) {}
};
(INT64 are UINT64 are not relevant to the discussion.)
I know some C, but very little C++ so I was somewhat puzzled. Is the
function inside the struct a constructor which will assign o to
offset and s to size?
So, I would write struct OFFSET_AND_SIZE toto(666, 999); and toto's
fields would be initialized as I expect, right?
What if I write struct OFFSET_AND_SIZE toto; would the compiler
complain, or would the fields remain undefined, as in C?
I came across the following definition (or is it declaration? I
never know):
struct OFFSET_AND_SIZE
{
INT64 offset;
UINT64 size;
OFFSET_AND_SIZE (INT64 o, UINT64 s) : offset (o), size (s) {}
};
(INT64 are UINT64 are not relevant to the discussion.)
I know some C, but very little C++ so I was somewhat puzzled. Is the
function inside the struct a constructor which will assign o to
offset and s to size?
So, I would write struct OFFSET_AND_SIZE toto(666, 999); and toto's
fields would be initialized as I expect, right?
What if I write struct OFFSET_AND_SIZE toto; would the compiler
complain, or would the fields remain undefined, as in C?