Can someone point me where did i do wrong on the coding below?
class Course {
private:
string nameCourse; <-- is this correct?
int totalOfCourses;
public:
void registerCourses(string course[], int numberOfCourses)
{
totalOfCourses = numberOfCourses;
for(int i=0; i<totalOfCourses; i++)
{
nameCourse = course[i];
}
}
void displayCourses()
{
cout << "Number of Courses: "<< totalOfCourses << endl;
for(int i = 0; i<totalOfCourses; i++)
{
cout << "Course taken: "<< nameCourse[i] << endl;
}
}
};
void setCourses(Course&);
int main()
{
Course c;
setCourses(c);
c.displayCourses();
system("pause");
return 0;
}
void setCourses(Course &crs)
{
int numCourse;
cout << "Enter number of courses: ";
cin >>numCourse;
string strCourse[j];
cout << "Enter courses taken: ";
for(int i=0; i<numCourse; i++)
{
//cin >> strCourse[i];
getline(cin,strCourse[i]);
}
crs.registerCourses(strCourse,numCourse);
return;
}