C++ program to implement output manipulation using sets & setfill

Create a C++ program that creates an array of integers. The Array is dynamic so you should use pointers to create it.

You need to ask the user for the length of the array, then ask the user to give inputs to the array members.

Once you are done, use a loop (for or a while loop), to sum the numbers of the array and then print the sum out.

#include “Course.h”
int main()
{
Student* demoData = new Student[3];
 
demoData[0] = Student(“James”);
demoData[1] = Student(“Mary”);
demoData[2] = Student(“Steve”);
 
Course class2110(“CSC2110”, demoData, 3);
 
class2110.printStudentInfo();
 
 
}
#include <string>
using namespace std;
#include <iostream>
class Student
{
private:
string name;
public: 
 
void setName(string n);
string getName();
Student();
Student(string n);
 
};
#include “Student.h”
 
void Student::setName(string n)
{
name = n;
}
 
string Student::getName()
{
return name;
}
 
Student::Student()
{
name = “not assigned”;
}
 
Student::Student(string n)
{
setName(n);
}
#include “Student.h”
class Course
{
private: 
string courseName;
Student* studentInfo;
int studentCount;
public:
void setCourseName(string n);
string getCourseName();
 
void printStudentInfo();
 
Student* getStudentInfo(int index);
Student* getStudentInfo(string name);
Course();
 
Course(string n, Student* stdInfo, int count);
~Course();
 
};
#include “Course.h”
 
void Course::setCourseName(string n)
{
courseName = n;
}
 
string Course::getCourseName()
{
return courseName;
}
 
void Course::printStudentInfo()
{
for (int i = 0; i < studentCount; i++)
{
cout << studentInfo[i].getName() << endl;
}
}
Student* Course::getStudentInfo(int index){   
if (index < 0 || index >= studentCount)
{
return NULL;// out of bounds 
 
}
else
{
Student* temp = new Student();
temp->setName(studentInfo[index].getName());
 
return temp;
}
}
 
Course::Course()
{
setCourseName(“Unavailable”);
studentInfo = NULL;
}
 
Course::Course(string n, Student* stdInfo, int count)
{
setCourseName(n);
// deep copy 
studentCount = count;
studentInfo = new Student[count];
 
for (int i = 0; i < count; i++)
{
studentInfo[i] = Student(stdInfo[i].getName());
}
}
 
Course::~Course()
{
delete[] studentInfo;
}