description of function is :system will allow the instructor to add a new course indicating its
course id and course name. Since the course ids are unique, the system should check whether or not the
specied course id already exists (i.e., whether or not it is the id of another course), and if the course
exists, it should not allow the operation and display a warning message.
Here it will not be allowed to use vectors I must use dynamic arrays. My question is that how can I store int and string values in one array ? Should I use structure or anything else ?
Here it will not be allowed to use vectors I must use dynamic arrays. My question is that how can I store int and string values in one array ? Should I use structure or anything else ?
if(ptr[count].cId==courseId)
You are using count as the index so it checks for only one, and its out of bounds at that. You also aren't keeping any data... new allocated new memory each time so your old data won't be used...
You also forgot:
class StudentReviewSystem
{
private:
Courses *ptr;
int how_many_courses; // TODO: use size_t instead of int
public:
StudentReviewSystem(): ptr(NULL), how_many_courses(0)
{
}
// TODO: write copy constructor and assignment operator=
~StudentReviewSystem()
{
delete[] ptr;
}
};
A much simpler solution would be not writing a StudentReviewSystem class, make ptr a global variable, and then make StudentReviewSystem::addCourse() a standalone global function named addCourse().