Jump to content
  • Advertisement
Sign in to follow this  
iram

array of object handles

This topic is 4514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
It should be:


srObject@[] list_of_Objects(100);


You were actually declaring an object handle to and array of srObjects. [wink]

Share this post


Link to post
Share on other sites
i tried that and it is throwing "Error : Expected data type"
i am using 2.5.0c

srObject@[] list_of_Objects(100);

Share this post


Link to post
Share on other sites
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:


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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!