Question: class Student { public: Student( ) = default; Student( std::string name, int id ); ~Student( ); std::string get_name( ) const; int get_id( ) const; double

class Student { public: Student( ) = default; Student( std::string name, int id ); ~Student( ); std::string get_name( ) const; int get_id( ) const; double get_exam_score( int exam_number ) const; double get_average( ) const; double get_exam_count( ) const; char get_letter_grade( ) const; void set_name( std::string name ); void set_id( int id ); void set_exam_score( int exam_number, double score ); void add_exam_score( double score ); std::ostream& write( std::ostream& strm = std::cout ) const; private: std::string _name; int _id{0}; std::vector _exams; }; Consider a collection of Students. In order to group the individual Student objects together, an array data structure will be used. In the following sections, four different versions of an array will be developed; the design will be refined in each successive version. Automatic Array of Objects The data structure might first be represented by the following class definition: class StudentArrayV1 { // version 1: automatic array of objects public: StudentArrayV1( ) = default; void write( ); private: const static int n_members = 5; Student members[n_members]; int number_of_students = n_members; }; Note how the object class StudentArrayV1 is composed of objects of another class, Student. Storage is provided for the information of five students. This composition of objects demonstrates a very useful and powerful aspect of object-oriented programming: complex data structures can be built using the composition of relatively simple individual elements in a hierarchical fashion. Put the definition for class StudentArrayV1 in project file StudentArrayV1.h; place the definitions of the constructor and write methods of the class in file StudentArrayV1.cpp. Because of the automatic size of the private data array members, and because we used modern C++ member initialization to set initial values for number_of_students, the constructor can be specified as default (this explicitly says that the default constructor behavior is acceptable). The array method write simply invokes the method Student::write (with no arguments) for each of the five array members. This design for an array class is not very practical, however. The problem lies in the way the constructor for individual Student objects worked in the previous lab. The moment that memory is set aside for a StudentArrayV1 object, the constructors for each of the five Student object elements of the array will be called. Test this behavior with a declaration and call to the write method in function main in file main.cpp. int main( ) {

Help me write the constructor and write method for V1 array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!