by phantombeta » Sun Sep 11, 2022 5:22 am
These aren't comparable. Classes in ZScript don't work the same way as in C++, they're always references, never values.
test whatever_stack[10]; is an array of class instances on the stack, test * whatever_heap = new test[10]; is an array of class instances on the heap. Neither is equivalent to the ZScript example in the OP, which is an array of pointers to class instances. The C++ version of vector_wrapper vec [3]; in your example would be vector_wrapper *vec [3];.
These aren't comparable. Classes in ZScript don't work the same way as in C++, they're always references, never values.
[c]test whatever_stack[10];[/c] is an array of class instances on the stack, [c]test * whatever_heap = new test[10];[/c] is an array of class instances on the heap. Neither is equivalent to the ZScript example in the OP, which is an array of pointers to class instances. The C++ version of [c]vector_wrapper vec [3];[/c] in your example would be [c]vector_wrapper *vec [3];[/c].