Create array of real C ++ objects
3 answers
Using:
Student s [10];
Creates an array of 10 Student
instances.
I think it is Student s [10][];
invalid.
But with C ++ I would not use arrays of C types, it is better to use classes like std::vector
C ++ 0x std::array
or which may not be available with non-modern standard libraries / compilers.
Example for the above using std::vector
#include <vector>
...
std::vector<Student> students(10);
And with std::array
:
#include <array>
...
std::array<Student, 10> students;
+4
source to share