Question: Use c++, don't use pointers Use separate source files and header files to create a class to represent students. A student object has attributes of
Use c++, don't use pointers
Use separate source files and header files to create a class to represent students.
- A student object has attributes of major (string) and credit hours taken (integer).
- Member functions (methods) are as follows (no additional ones may be created):
- Using a constructor initializer list, create a constructor with default parameter values of General Studies and -1, and that displays \tConstructor called for major
and hours , replacing and with attribute values. - individual const get methods (in-line definition) for each attribute
- a const get method (NOT in-line) that uses pass-by-reference for both parameters and has return-type void
- one set method (NOT in-line) that sets both attributes
- PrintMe method (NOT in-line) that returns string Im a
major and have completed credit hours., replacing and with the appropriate attribute values - Destructor (in-line) that displays \tDestructor called for
major. , replacing with the appropriate attribute value
- Using a constructor initializer list, create a constructor with default parameter values of General Studies and -1, and that displays \tConstructor called for major
Write a complete program that uses the student class you created and tests its functionality:
- Declare a single student object and during declaration initialize it to have major Astrophysics; do not provide a value for number of credit hours
- Call the PrintMe method of the single student object and display to the screen/console
- Ask the user for the name of a file to which output should be written
- Declare a vector of 5 objects of student class
- Ask the user for 5 majors and 5 credit hours and assign them to each student in the vector. The credit hours must be verified as non-negative or else get another number. This must be tested in your output.
- Open the file and write to it using the value returned by PrintMe for every student in your vector
- Explicitly close the output file
- Any other tests you deem appropriate to prove your program works perfectly
In order to properly capture the destructor messages, put a breakpoint on the return statement in main. When the program pauses at that line, press F10 once, capture the output screen as a snippet, then press F5 to finish execution.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
