In a.h, I created an array without the extern
keyword by mistake which should result in a tentative definition
a.h:
MyStruct myArrayOfStructs [];
This array is then defined in a.cpp
a.cpp:
MyStruct myArrayOfStructs[CONSTANT];
This surprisingly compiled.
Why did the compiler not complain about redefinition?
That is perfectly valid. The first (.h
) says there exists an array somewhere, but does not instantiate it.
The second allocates it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With