i have two c++ classes, one which inherits an abstract base class for a student database. The base class is the record which contains all the student information (name, id vector of courses & marks):
class student{
protected:
string fName,sName;
int id;
vector<string> cname;
vector<double> cmark;
public:
virtual ~student();
virtual void addClass(string name, double mark)=0;
};
I Need to be able to access the vector cname and cmark in the addCourse
function in the below class
class degree : public student{
public:
degree(string f, string s, int i){
this->setName(f,s);
this->setID(i);
}
~degree();
void AddCourse(string name, int mark){
}
I dont know how to do this without making a set
function in the base class like i have done with the degree
constructor.
I could just make a set function in the base class but i would rather some method of initializing the inherited elements without using functions, just to make the code less messy, is this possible? i thought about using this->cname
but that gave me errors.