Mail Archives: djgpp/2008/10/19/09:59:24
-----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-----
- Raw text -