Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#1 [8 points] The following class keeps track of how many students are at CollegeA and the number of classes each of them have taken

#1 [8 points]

The following class keeps track of how many students are at CollegeA and the number of classes each of them have taken in Spring 2020. The classes for each student are positive values of type unsigned int and are stored as a dynamically allocated array. The first data member is a pointer that will point to the first element of the array. This array will be of an arbitrary size. The default size of the array shall be 50, but may be specified by the user at the time of construction. The second data member represents the size of the array, i.e. the number of students at CollegeA, and is stored as unsigned int.

class Spring2020 { private: unsigned int* classes; unsigned int num; public: // constructors (default, one arg, and copy) Spring2020(); Spring2020( unsigned int numberOfStudents); Spring2020( const Spring2020& original); // destructor ~Spring2020(); // Member function int classesAtIndex( int index ); };

a.) If this is in the Class Specification (header) file Spring2020.hpp, write the function definitions that would be in the Class Implementation (source) file Spring2020.cpp.

b.) Why must the parameter of the copy constructor be of type constant reference?

Hint: Recall the discussion in class about constant reference. But this question seeks answers beyond that. Here we are passing constant reference, but as parameter to a copy constructor.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

How did you feel about taking piano lessons as a child? (general)

Answered: 1 week ago