Jump to content
  • Advertisement

Archived

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

KrunkSplein

Constructors on dynamic arrays...

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

Okay. Having trouble wording this in English. Let me show you some code, then I''ll go on from there: cPermList::cPermList( int N ) { const int nfac = (const int)factorial(N); size = N; list = new cBaseInt[ nfac ](N, N); } Should note that the cBaseInt constructor takes two ints as arguments in the constructor I wish to use. My trouble is this (though Im sure other problems will be pointed out to me): How do I declare an array of objects that are to be made using the same constructor and the same values? Is the "list = new cBaseInt[ nfac ](N, N)" line right or very wrong? And while I have your attention, will that const int cast work? --------- Krunk

Share this post


Link to post
Share on other sites
Advertisement
Unfortunately, straight from MSDN:
quote:

Arrays are constructed only using the default constructor. Default constructors are constructors that either accept no arguments or for which all arguments have a default. Arrays are always constructed in ascending order. The initialization for each member of the array is done using the same constructor.

You have to initialize each element individually using a loop or library algorithm.

quote:
And while I have your attention, will that const int cast work?

The cast to the const type will be done implicitly, so you don't need the explicit cast. Yes, it should work.

[edited by - Zipster on January 31, 2003 11:01:28 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!