• Advertisement

Archived

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

Objects within an array

This topic is 5434 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

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
Advertisement
Yes, you can put them in an array. What are your problems?

It may be that you need a default constructor.

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

  • Advertisement