I want to create in C++ an array of Objects without using STL.
How can I do this?
How could I create array of Object2, which has no argumentless constructor (default constructor)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the type in question has an no arguments constructor, use
new[]:don’t forget to call
delete[]when you no longer need the array:If it doesn’t have such a constructor use
operator newto allocate memory, then call constructors in-place:Again, don’t forget to deallocate the array when you no longer need it.