Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ only please. Create a class StudentList that contains Student objects. It has the following data members: class StudentList{ private: static const size_t LIST_SIZE =

C++ only please.

Create a class StudentList that contains Student objects. It has the following data members:

class StudentList{ private: static const size_t LIST_SIZE = 150; // the maximum items in the list

Student *items; // items will point to the dynamically allocated

array size_t numItems; // the number of items currently in the list

public: // member functions to be defined by to be defined and completed by YOU! Hooray!

}

The class should have the following member functions:

- One or multiple constructors - A copy constructor

- A function that prints all the students names.

- A function that checks if a student exists in a list by given either the ID or the names.

- Accessing functions

- A destructor Create a driver to test the class.

Submit the files: slist.h, slist.cpp, slisttest.cpp

#####################################################################

student.h

--------------

#ifndef STUDENT_H #define STUDENT_H

class Student{

public: Student(char*, char*, int); // Constuctor Student(const Student &); // Copy Constuctor ~Student(); // Destructor void display(); // function to display student info

private: char* fname; char* lname; int id; };

#endif // STUDENT_H

########################################################

student.cpp

----------------

#include #include #include "Student.h"

using namespace std;

Student::Student(char* pF, char* pL, int idnum){ id = idnum; fname = new char[strlen(pF)+1]; lname = new char[strlen(pL)+1]; strcpy(fname, pF); strcpy(lname, pL); }

// Constructor Student::Student(const Student &stud){

id = stud.id; fname = new char[strlen(stud.fname)+1]; lname = new char[strlen(stud.lname)+1]; strcpy(fname, stud.fname); strcpy(lname, stud.lname); }

Student::~Student(){ delete [] fname; delete [] lname; }

void Student::display(){ cout<<"Id: "<

##########################################

stest.cpp

------------------

#include #include #include "Student.h"

using namespace std;

int main(){

char fnmae[50], lname[50]; int id;

cout<<"Enter student id: "; cin>>id;

cout<<"Enter first name: "; cin>>fnmae;

cout<<"Enter last name: "; cin>>lname;

// Creating Student Object Student std(fnmae, lname, id);

// printing info std.display();

return 0; }

THANK YOU!!

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

2. Why has the conflict escalated?

Answered: 1 week ago