Hey all, I need help with a small problem... I have to declare a class called Module. And in the main function I have to declare an array of type Module. Then I have to ask the user to type in the 5 modules they are registered for and the marks for assignment 1 and assignment 2 for each module... I don't know how to "save" the input from the user into the array and then the class? After that I have to determine the semester mark, but that is not difficult, I just need help with the input. This is what I have so far:
#include <iostream>
#include <string>
usingnamespace std;
class Module
{
public:
void setMods(string moduleX, int ass1, int ass2);
string get_module();
int get_ass1marks();
int get_ass2marks();
private:
string module;
int ass1marks;
int ass2marks;
};
int main()
{
Module mods_ass[5];
string moduleName;
int assOne, assTwo;
for (int i = 1; i <= 5; i++)
{
cout << "Enter the name of module " << i << ": ";
cin >> //here I had mods_ass[i].module the the error says:
//error: 'std::string Module::module' is private
//error: within this context
cout << "Enter the marks for Assignment 1" << ": ";
cin >> //the same goes here
cout << "Enter the marks for Assignment 2" << ": ";
cin >> //the same goes here
}
return 0;
}
void Module::setMods(string moduleX, int ass1, int ass2)
{
module = moduleX;
ass1marks = ass1;
ass2marks = ass2;
}
string Module::get_module()
{
return module;
}
int Module::get_ass1marks()
{
return ass1marks;
}
int Module::get_ass2marks()
{
return ass2marks;
}