By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

constuctors and object arrays

P: n/a
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
Mar 20 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 20 Mar, 12:23, "tripleF" <s...@night.co.ukwrote:
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<Objectv(5, Object(1,1));

--
Erik Wikström

Mar 20 '07 #2

P: n/a
This was multiposted to comp.lang.c++.moderated. Please do not
multipost nor crosspost when unnecessary.

tripleF <sk*@night.co.ukwrote:
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.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Mar 20 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.