From the course: Learning C++

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Using functions

Using functions - C++ Tutorial

From the course: Learning C++

Using functions

- [Instructor] You may have noticed that there's one function left to implement. This is the get GPA function. In this function, we'll use most of the functions we have just written. In the main source file, this is between lines 27 and 34. So let me cut and leave a to do comment as usual. Now let's adapt the code in records.cpp. The first change is in line 90. Notice that the type of GRD is referenced to grade. Now since we are inside a getter function that enforces cons correctness, this type is in conflict. Yes, that constant qualifier at the end of line 88 means that the code inside the function cannot modify this student records object. So to solve this inconsistency, we can pledge never to modify GRD by simply adding a const qualifier to it. The second change is in line 91, the ID is our parameter called SID. Then in line 92 we have the note I left to get the numeric grade from the letter grade. So we could do it…

Contents