X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Date: Sun, 19 Oct 2008 15:52:31 +0200 From: alex bodnaru Subject: Re: question for c++ experts In-reply-to: <516fae4a0810190550v6a545ab8s776cf48ccbf75cbc@mail.gmail.com> To: djgpp AT delorie DOT com Message-id: <48FB3B9F.3050002@resheteva.lan> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-Enigmail-Version: 0.95.7 References: <516fae4a0810190550v6a545ab8s776cf48ccbf75cbc AT mail DOT gmail DOT com> User-Agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724) Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi valentina, you have to supply a default constructor like A(float a=0.0); your array will be filled with such objects, and then you should change them as you wish. the static way to fill an array works for primitive types, not objects. but you may define a static array of A objects, and update the array of objects from the floats array values. if you really insist, you may come to a closer result, but not necessarily better, easier or cleaner. alex Valentina Poletti wrote: > I have a class, A, whose constructor necessitates a parameter, say a float. > > class A { > public: > A(float); > } > > now, I want to create an array of such classes > > A* array; > array = new A[4]; > > but how do I pass the parameter? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iJwEAQECAAYFAkj7O58ACgkQ2nA3WyrfyeNGngQAiX2+lkaed3l9hTRDDU6RM2Ag 5joXo/uGdsnXQDe8c/i8zpijIXpEL4Npac/+9VY+Md1fMtJucWawIT2Q9wEMn8Mt OUt+iCtl7Cq6mLlCQ7aD2BUMKISx+usOT15dZmCUPDRZeBZOezGbU8YdXTl0H4UT Kg18LDpvxTsoWmann+o= =Kl+7 -----END PGP SIGNATURE-----