I want to create an array to store actual objects and not pointers to objects in C++?
Can somebody explain how do I do that? is it better to use vectors or just directly like:
Student s [10];
OR
Student s [10][];
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.
Using:
Creates an array of 10
Studentinstances.I think that
Student s [10][];is invalid.But with C++ I’d not use C type arrays, it’s better to use classes like
std::vectoror C++0xstd::arraywhich may not be available with not up-to date standard libraries/compilers.Example for the above with a
std::vectorAnd with an
std::array: