Advertisement

array of struct inside a struct

Started by December 07, 2005 10:15 AM
5 comments, last by WitchLord 18 years, 11 months ago
I'm trying to make an array of a struct inside a struct. Like this:

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?
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.
Advertisement
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks for the help!
Resize seems to be an undocumented feature, as it's nowhere in the docs. ;)
You're right. I had forgotten to document that. Thanks for letting me know.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.
Advertisement
Thanks! [smile]

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement