I just need help on how to create a pointer to a list of students and make it a private member of the class. This for my data structures class and is our Program #2, which will be derived from Program #1, which I put the partial code for it down below. Thanks for all your help.
Write a C++ object-oriented program to manage a file system for students:
First Name – string
Last Name – string
Student ID – unsigned integer
Email – string
GPA - float
The program will manipulate the student list based on students from the file students.dat
Class requirements
1. Create a student class or struct based on the student structure
2. Create a students class which contains two private members – a pointer to a list of students and a function to print a student’s record. The students class will also provide the following functionality.
a. Load data from a data file into a student list
b. Retrieve and print a student from the student list
c. Insert a student into the student list
d. Delete a student from the student list
e. Print the contents of a student record
f. Print the contents for a list of students
g. Sort the student list by last Name
h. Sort the student list by GPA
Processing requirements
1. Load the students file students.dat
2. Create a menu to carry out the given operations
3. Implement input validation to avoid erroneous program errors
Structure of the file
students.dat – First Name, Last Name, Student ID, Email, GPA
Smith Jefferey 891789 j.smith@spartans.nsu.edu 3.75
Lee Jackson 3678902 j.lee@spartans.nsu.edu 3.66
Gonzales Mariana, 168790 m.gonzales18@spartans.nsu.edu 4.0
Jones Mike 8973125 m.jones143@spartans.nsu.edu 3.1
Williams Anita 2985465 a.williams@spartans.nsu.edu 3.64
Ronsinson Taylor 3278976 t.robinson@spartans.nsu.edu 3.55
Clark Allen 1094567 a.clark@spartans.nsu.edu 3.48
Turner Tavon 318796 t.turner@spartans.nsu.edu 3.2
Jenkins Nelson 289563 n.jenkins@spartans.nsu.edu 3.0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
// Name: Mysia Elliott
// Date: September 4th, 2018
// Class: Fall 2018 - Data Structures - CSC 372 - SEC 01 - 78142
// Professor: Dr. Graham
// Program Description: This program uses knowledge of structs and classes to manage a file system for students at Norfolk State University.
// The program will also manipulate the student list based on student information from a file written into an array.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct studentInfo // Definition of struct named studentInfo
{
string firstName; // Variable that holds a student's first name
string lastName; // Variable that holds a student's last name
unsigned int studentID; //Variable that holds a student's student ID
string email; // Variable that holds a student's e-mail
float gpa; // Variable that holds a student's GPA
};
class studentsProc // Definition of class named studentsProc
{
public:
void loadList(); // Function that loads data from a data file into a student list
void retrieveStudent(); // Function that retrieves and prints a student's information from the student list
void insertStudent(); // Function that inserts a student's information into the student list
void deleteStudent(); // Function that deletes a student's information from the student list
void printStudent(); // Function that prints the contents of a student's record
void displayStudentList(); // Function that prints the contents for a list of students
void sortLastName(); // Function that sorts the student list by students' last names
void sortGpa(); // Function that sorts the student list by GPA
void studentList(); // Function that displays list of students' names the user can choose from
studentsProc(); // Constructor
private:
studentInfo students[40]; // Array of type studentInfo containing student's information
int size; // Size of the array
void printList() const; //Print the contents of the list
};
|