struct test{
int a;
};
struct test2{
test[] b(2);
};
This gives me a compiler error about the array. I was wondering, if this is actually possible in Angelscript, or do I have a syntax error?
[edit]
Come to think of it, is it possible to declare any kind of array inside a struct?
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
array of struct inside a struct
I'm trying to make an array of a struct inside a struct. Like this:
What you have to do is
struct test2
{
test[] b;
};
then once you create an instance of test2, do test2.b.resize(2).
This worked for me, although im sure WitchLord will reply soon if there is a better alternative.
struct test2
{
test[] b;
};
then once you create an instance of test2, do test2.b.resize(2).
This worked for me, although im sure WitchLord will reply soon if there is a better alternative.
Indeed, you cannot specify the size of the array in the struct declaration.
Soon enough I will implement support for constructors and class methods, which would be the place for initializing the array by resizing it.
Regards,
Andreas
Soon enough I will implement support for constructors and class methods, which would be the place for initializing the array by resizing it.
Regards,
Andreas
Thanks for the help!
Resize seems to be an undocumented feature, as it's nowhere in the docs. ;)
Resize seems to be an undocumented feature, as it's nowhere in the docs. ;)
Quote: Original post by WitchLord
You're right. I had forgotten to document that. Thanks for letting me know.
and while you are at it, you can document .length() too :)
I only knew about those methods because I been diving in the source.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement