****************************Instructions***************************** Add a "copy constructor" to your dynamic-array student. Remember, the prototype looks like: Classname(const classname& otherObject); Update your test program to use the copy constructor. e.g., CourseTypeList list2(list1); ********************************************************************* Submit: Updated test program, implementation and header files (.cpp and .h) for CourseListType and CourseType zipped into a single file. //courseTypeList.h #ifndef COURSELISTTYPE_H_INCLUDED #define COURSELISTTYPE_H_INCLUDED #include #include "courseType.h" class courseTypeList { public: void print() const; void addCourse(std::string); courseTypeList(int n); ~courseTypeList(); private: int NUM_COURSES; int courseCount; courseType *courses; }; #endif // COURSELISTTYPE_H_INCLUDED =============================================== //courseTypeList.cpp #include #include #include "courseTypeList.h" void courseTypeList::print() const { for (int i = 0; i < courseCount; i++) { courses[i].printCourse(); } } void courseTypeList::addCourse(std::string name) { courses[courseCount].setCourseName(name); courses[courseCount].setCourseID(1000+courseCount); courseCount++; } courseTypeList::courseTypeList(int n = 50) {    courseCount = 0;    courses = new courseType[n];    NUM_COURSES = n; } courseTypeList::~courseTypeList() {    delete &courses; } =============================================== //courseType.h #ifndef COURSETYPE_H_INCLUDED #define COURSETYPE_H_INCLUDED #include #include using namespace std; class courseType { public: courseType(int, string); courseType(); int getCourseID(); string getCourseName(); void setCourseID(int); void setCourseName(string); void printCourse(); private: int courseID; string courseName; }; #endif =============================================== //courseType.cpp #include "courseType.h" #include using namespace std; courseType::courseType(int id, string name) { this-> courseID = id; this-> courseName = name; } int courseType::getCourseID() { return courseID; } string courseType::getCourseName() { return courseName; } void courseType::setCourseID(int id) { courseID = id; } void courseType::setCourseName (string name) { courseName = name; } courseType::courseType() {    this-> courseID = 0; this-> courseName = ""; } void courseType::printCourse() { cout << "Course ID: " << getCourseID() << endl; cout << "Course Name: " << getCourseName() << endl; } =============================================== //test.cpp #include"courseTypeList.cpp" #include using namespace std; int main() {    courseTypeList c1(10);    c1.addCourse("CSC");    c1.addCourse("Physics");    c1.print(); } =========================================

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

****************************Instructions*****************************

  • Add a "copy constructor" to your dynamic-array student. Remember, the prototype looks like:
    • Classname(const classname& otherObject);
  • Update your test program to use the copy constructor.
    • e.g., CourseTypeList list2(list1);

*********************************************************************

Submit: Updated test program, implementation and header files (.cpp and .h) for CourseListType and CourseType zipped into a single file.

//courseTypeList.h

#ifndef COURSELISTTYPE_H_INCLUDED
#define COURSELISTTYPE_H_INCLUDED

#include <string>
#include "courseType.h"

class courseTypeList {

public:
void print() const;
void addCourse(std::string);
courseTypeList(int n);
~courseTypeList();

private:
int NUM_COURSES;
int courseCount;
courseType *courses;
};

#endif // COURSELISTTYPE_H_INCLUDED

===============================================

//courseTypeList.cpp

#include <iostream>
#include <string>
#include "courseTypeList.h"

void courseTypeList::print() const {

for (int i = 0; i < courseCount; i++) {
courses[i].printCourse();
}
}

void courseTypeList::addCourse(std::string name) {
courses[courseCount].setCourseName(name);
courses[courseCount].setCourseID(1000+courseCount);
courseCount++;
}


courseTypeList::courseTypeList(int n = 50)
{
   courseCount = 0;
   courses = new courseType[n];
   NUM_COURSES = n;
}

courseTypeList::~courseTypeList()
{
   delete &courses;
}

===============================================

//courseType.h

#ifndef COURSETYPE_H_INCLUDED
#define COURSETYPE_H_INCLUDED
#include <iostream>
#include <string>

using namespace std;

class courseType {

public:
courseType(int, string);
courseType();

int getCourseID();
string getCourseName();

void setCourseID(int);
void setCourseName(string);

void printCourse();

private:
int courseID;
string courseName;

};

#endif

===============================================

//courseType.cpp

#include "courseType.h"
#include <string>

using namespace std;

courseType::courseType(int id, string name) {
this-> courseID = id;
this-> courseName = name;
}

int courseType::getCourseID() {
return courseID;
}

string courseType::getCourseName() {
return courseName;
}

void courseType::setCourseID(int id) {
courseID = id;
}

void courseType::setCourseName (string name) {
courseName = name;
}


courseType::courseType()
{
   this-> courseID = 0;
this-> courseName = "";
}

void courseType::printCourse() {
cout << "Course ID: " << getCourseID() << endl;
cout << "Course Name: " << getCourseName() << endl;
}

===============================================

//test.cpp

#include"courseTypeList.cpp"
#include<iostream>
using namespace std;

int main()
{
   courseTypeList c1(10);
   c1.addCourse("CSC");
   c1.addCourse("Physics");
   c1.print();
}

=========================================

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education