Need help with OOP (Set and Get Functions).

Suppose I have a class called Student with private member variables and public member functions. There are two functions, a set and get function to retrieve the total test score. The segment of code where I need assistance is below,

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;
class Student{
private:
double testOne;
double testTwo;
public:
void setTestScores(); //This function has to calculate the total test score.
double getTestScores();
}
void Cake::setTestScores() //Here is the declaration of the function.
double Cake::getTestScores(){return Total;}


My question is that how would you make it so the getTestScores function returns the total using the calculation from the setTestScores function?
Last edited on
You could pass the 2 test scores to setTestScores and store it in testOne and testTwo.
In getTestScores you return testOne + testTwo
Topic archived. No new replies allowed.