constuctors and object arrays

T

tripleF

I want to pass parameters to the consructor when i create an array of
objects like this for a single object

Object *pSprite;

pSprite=new Object(1,1);

dynamicly created object array

Object *pSprite;

pSprite=new Object[5];

How do i combine the two
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

I want to pass parameters to the consructor when i create an array of
objects like this for a single object

Object *pSprite;

pSprite=new Object(1,1);

dynamicly created object array

Object *pSprite;

pSprite=new Object[5];

How do i combine the two

You don't, but you can use a vector to much the same effect:

std::vector<Object> v(5, Object(1,1));
 
M

Marcus Kwok

This was multiposted to comp.lang.c++.moderated. Please do not
multipost nor crosspost when unnecessary.

tripleF said:
I want to pass parameters to the consructor when i create an array of
objects like this for a single object

Object *pSprite;

pSprite=new Object(1,1);

dynamicly created object array

Object *pSprite;

pSprite=new Object[5];

How do i combine the two

Answered in comp.lang.c++.moderated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top