Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COthanks for this explanation. are there any arguments against using const in a function that doesn't change the object? I feel that software could get less flexibly maintainable if you suddenly decide for example to change some design and need to call a non const function in a currently as const declared function and then maybe a big chain of functions that call this function have to be changed too
      singulars
    2. CONo, there is no argument against using a `const`. That is, unless you know right now, at the time of designing your class, that a member function should be allowed to change the object. It's a design question that you should ask yourself early on, and it should easy to answer. It's not about "leaving the door open for later". Rather, it's about whether the function **should** change the object or **should not** change it. It's a yes/no question, black or white, with nothing in between, and it should be easy to answer. Note: it's not about **may** it change the object, but **should** it.
      singulars
    3. COThis in turn means the const-correctness philosophy forces you early on to be very conscious about what each function does. It forces you to decide and be very clear about the raison d'être of each of the member functions. That's a Good Thing. What you're asking is to leave a door open for changing the raison d'être of a function, and that's a Bad Thing. You should only change **how** a function gets what it's meant to do done, not **what** it does. Think about the users of your API (which well be you yourself). Don't pull the rug off their feet!
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload