CS202 Computer Science II
Assignment 5
Due Nov 2 before class
Last modified 10/20/98 @ 12:00 p.m.
This assignment gets you familiar with dynamic memory, pointers, and
operator overloading. You also get the pleasure of sorting again.
As5 is very similar to assignment three.
The difference is that you need to implement a dynamically allocated
StudentVector class instead of using an array of
Student structs. Specifically,
You are to design a StudentVector class, that encapsulates a
dynamic array of Student structs. You will need to
specify and implement
- Constructors
- A destructor
- A copy constructor
- Overloaded assignment
- Overloaded subscript operator []. Yes it is an operator.
- Overloaded << and >> (I/O) operators
- Friends for sorting and searching
- Other members that you may need
The subscript ([]),
input (>>), and output (<<) operators
will be overloaded. You will use a Student struct that is
very similar to the one you used in
assignment three.
Look at my bubblesort.cpp
(which you cannot modify) for more information on constraints for
this assignment.
as5.cpp
therefore looks even simpler than
as3.cpp. You must take and use
my bubblesort.cpp and
command.cpp. I have also taken the liberty of shortening
ProcessCommandLine to PCL in my version of
command.cpp.
You can use the test cases from
assignment three to test your program with
my input file.
Constraints
-
You should put your struct declaration(s) in a file called
type.h and your program in
as5.cpp.
- You may assume that if there is one command line argument it must be the
number of records to sort and you sort by gpa. If there are two
command line arguments then the first determines the number of records to
sort and the second defines the sort field.
- You may use the string library function strcmp() to compare
two strings. Follow the link to read the manual page and learn how to use
strcmp().
- NO global variables.
- You may NOT assume a maximum size for any arrays (except for the
name field for a student).
- You must define and use a swap() function that passes structures
by reference to swap items in your array of structs.
This is the most difficult assignment you have had so
far. Start on the assignment now and ask questions.