🎉 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 object handles
i have declared an object class myself.
now i wanted to have an array of them, but cannot seems to be able to do it correctly.
srObject@ Object_shape; //1 object
srObject[] @list_of_Objects (100); //Error: only objects have contructors
It should be:
You were actually declaring an object handle to and array of srObjects. [wink]
srObject@[] list_of_Objects(100);
You were actually declaring an object handle to and array of srObjects. [wink]
i tried that and it is throwing "Error : Expected data type"
i am using 2.5.0c
srObject@[] list_of_Objects(100);
i am using 2.5.0c
srObject@[] list_of_Objects(100);
I've been trying to reproduce your problem, and so far everything works as it should without any compiler errors. I can compile the following script without any problems:
Perhaps it has to do with how you registered the srObject type. Can you show us how you've registered the type, including the behaviours? Also, can you show us the exact error messages that you're getting, as well as the script lines they refer to?
Regards,
Andreas
string@[] c(10);
Perhaps it has to do with how you registered the srObject type. Can you show us how you've registered the type, including the behaviours? Also, can you show us the exact error messages that you're getting, as well as the script lines they refer to?
Regards,
Andreas
interesting.....
i tried to use your example, and string is registered per AS sample.
string@[] c(10); //this is a line 27
error message returned:
as (27, 13) : Error : Expected data type
Include the <vector> header file and use vector stl.
std::vector<srObject@> object_array;
Now resize the vector of objects to what ever size N you want.
object_array.resize(N);
Now you can use the vector just like an array.
object_array[0], object_array[1], object_array[2], .... , object_array[N]
Just make sure that you boundary check when you are tring to access an element in the vector/array.
Just make sure that you clear the vector, and free up the memory being used by the Objects in the vector/array.
std::vector<srObject@> object_array;
Now resize the vector of objects to what ever size N you want.
object_array.resize(N);
Now you can use the vector just like an array.
object_array[0], object_array[1], object_array[2], .... , object_array[N]
Just make sure that you boundary check when you are tring to access an element in the vector/array.
Just make sure that you clear the vector, and free up the memory being used by the Objects in the vector/array.
I'm also wondering what the @ token means in C++. Is this something available in a newer version of C++ that I'm not aware of? [wink]
iram:
Which character is on the 13th column? Is it the c? Or @? Or []?
Are you declaring the array as a global variable? It could be that it would be parsed differently. I'll test that.
Regards,
Andreas
iram:
Which character is on the 13th column? Is it the c? Or @? Or []?
Are you declaring the array as a global variable? It could be that it would be parsed differently. I'll test that.
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement