This way you can do: #include <iostream>
using namespace std; class A { public: int a; A(int m) { a = m; } A() { } }; int main() { int i; A *obj[32]; for ( i = 0; i <= 31; i++ ) { obj[i] = new A(i); } for ( i = 0; i <= 31; i++ ) { cout << obj[i]->a << endl; } return 0; } On Tue, May 24, 2011 at 9:38 PM, immanuel kingston < kingston.imman...@gmail.com> wrote: > > http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectsbyreferencingtheconstructordirectly.htm > > > http://www.java2s.com/Tutorial/Cpp/0180__Class/Initializeanarrayofobjectswithoutreferencingtheconstructordirectly.htm > > Thanks, > Immanuel > > > > On Wed, May 25, 2011 at 7:34 AM, D.N.Vishwakarma@IITR > <deok...@gmail.com>wrote: > >> There is a class A which contains just one parameterized constructor >> A(int a). How would you initialize an array of objects of this class. >> >> -- >> **With Regards >> Deoki Nandan Vishwakarma >> IITR MCA >> Mathematics Department* >> * >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- -Aakash Johari (IIIT Allahabad) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.