Hello everyone, this is my first post here and I've tried searching everywhere for it, but perhaps I'm wording my search incorrectly.
The problem I'm having is using a class function to assign a value to a variable. I have two classes - undergrad (base class) and grad (inherits undergrad).
#ifndef GRAD_H_INCLUDED
#define GRAD_H_INCLUDED
#include <iostream>
#include <string>
#include <vector>
#include "undergrad.h"
usingnamespace std;
//Object class that inherits undergrad but allows the addition of fees and recalculates tuition.
class grad : public undergrad
{
public:
grad();
grad(double studFees);
void setFees(double newFees);
double getFees() const;
double totalTuition();
private:
double fees;
};
inline grad::grad() { fees = 0.0; }
inline grad::grad(double studFees) { fees = studFees; }
inlinevoid grad::setFees(double newFees) { fees = newFees; }
inlinedouble grad::getFees() const { return fees; }
inlinedouble grad::totalTuition()
{
undergrad x; grad y;
double newTuition;
newTuition = x.totalTuition() + y.getFees();
return newTuition;
}
#endif
As you can see, I use 2 class functions to try to assign a value to newTuition and the result is 0. The requirement for the project is to use the base class function call instead of using the private members directly.
If anyone can provide any guidance, I'd greatly appreciate it. Thank you.