Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
If you don't want to copy the parameter (time and memory constraints), but want to use it without altering it, you pass it by const reference.
if you don't want to change number you shouldn't pass it as a reference
Because he is passing
number
as a reference.This would mean if he would change
number
in the body ofopposite
, the value would be also manipulated outside the function.This is clearly not wanted.
const
declares that number will be treated as constant in this function and has two purposes:number
as a reference, it will not be changedopposite
can not accidently changenumber
as this would result into a compilation error.