Repository navigation
grade-school: Force const on roster() and grade() - #287
Conversation
Currently school::roster() and school::grade() can be implemented as non-const methods. Logically it makes sense to be able to call those two methods on a const instance because they should not modify that instance.
|
I accidentally deleted my previous (identical) PR. |
|
The CI is failing because of this. We test against Clang 3.8 since last I checked it was still the default in something (probably an Ubuntu LTS build, 16.XX?). For now we should support that until we update the compilers, so you'd need to add a default constructor to the example. I would suggest actually adding a brief comment to the added constructor to explain why there is otherwise unnecessary code. This is a good change though :) |
|
Good catch! |
|
Wow that's...interesting. Let's do value initialization as you suggested so we don't force the students to deal with that. |
Currently school::roster() and school::grade() can be implemented as
non-const methods. Logically it makes sense to be able to call those two
methods on a const instance because they should not modify that
instance.