Archived

This topic is now archived and is closed to further replies.

exodus7

Objects within an array

Recommended Posts

Ok I want to put objects I''ve creating into an array. Can I do this? I seem to be having problems would it be better to put them in a structure? I’m using c++ thanks there is only one way

Share this post


Link to post
Share on other sites
I''ve got 9 objects of class CRect that hold the postions of 9 rectangles.

I want to put these into any array.

Example:
CRect rect1, rect2........

SetRect(rect1,topx,y,so on.......)

I''ve done this for all nine objects.

How do I know store that data in an array?


Share this post


Link to post
Share on other sites
Guest Anonymous Poster

SetRect(rect[0],x,y,so on....); //first rectangle

Will create a copy of rect[0] and pass that to the setRect function. when the function returns, rect[0] will be unchanged. you might want to pass rect[0] by reference. in this case calling

SetRect(rect,x,y,so on....); //first rectangle

will change the values in rect[0].

Share this post


Link to post
Share on other sites