Very new to C++. Could use some help with this assignment on classes. The assignment requirement is:
Create a class called CourseList that includes one instance variables— nameOfCollege (type String). Provide a displayMessage member function to welcome the user to the CourseList program. Provide a set function that sets the name of the college, and a get function that retrieves the name of the college. The set function should have one string parameter for the name of the college. Use the function main() to demonstrate class Course’s capabilities.
To demonstrate our understanding of classes, we are to create classes, with objects, with functions. The end result is a console app to view fake classes offered at a fake college.
Currently, my get function is not returning the string with my fake college name. This is what I'm trying to resolve currently. I think my issue is with how I've written my functions or how my objects have been constructed.
Here is my code:
// DJ Homework
// welcome function [done]
// set function w/ college name in parameter [maybe done?]
// get function [not done]
// return string [not done]
// display class list [not done]
#include <iostream>
#include <string> // program uses C++ standard string class
using namespace std;
// CourseList class definition
class CourseList
{
private:
// string here
string nameOfCollege;
public:
void setCollegeName(string nameOfCollege);
string getCollegeName();
void CourseList::mysetCollegeName(string nameOfCollege)
{
nameOfCollege = "Smart Peoples University";
}
string CourseList::mygetCollegeName()
{
return string();
}
// function that displays a welcome message to the CourseList user
void displayMessage(string nameOfCollege) const
{
cout << "Welcome to the CourseList Program\n\n\n" << "To see the classes offered at " << nameOfCollege << ",type something, then press 'Enter'.";
} // end function displayMessage
}; // end class GradeBook
// function main begins program execution
int main()
{
string CollegeName; // string of characters to store the college name
CourseList myWelcome; // create a CourseList object named myWelcome
myWelcome.displayMessage(CollegeName);
} // end main
So that's my homework and attempt at accomplishing said tasks. Any help with my assignment, or with C++ in general, would be greatly appreciated.
mysetCollegeName()as well assetCollegeName()? And instead of passing the college name into thedisplayMessage()function shouldn't that print out the member variablenameOfCollege?