Some questions on C++ struct and array -
I'm relatively new to C ++ and I'm having trouble understanding the structure.
I have a straight declaration
struct MyNode {int level; Int index Minor children [4]; }
However code C2488 fails to compile and report error: The total size of the array should not exceed 0x7fffffff bytes.
but the following code compiles
struct MyNode {int level; Int index Minorod * Children; }
Can I code for as a first example or maybe something that I am missing.
Thank you!
This fails to compile, because the compiler needs to know each type of size. So, what is sizeof (MyNode)
? This is the sizeof (int) * 2 + sizeof (MyNode)
: makes the recurrence size impossible to understand.
As your second example, why does this work? Because sizeof (MyNode *)
is known: This target is an address-size on the platform.
Comments
Post a Comment