Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler errors about const specifier in getter functions #127

Open
tonimueller opened this issue Mar 18, 2021 · 0 comments
Open

Compiler errors about const specifier in getter functions #127

tonimueller opened this issue Mar 18, 2021 · 0 comments

Comments

@tonimueller
Copy link
Member

A lot of getter functions are written like

const type getValue() const {return value;} 

where the compiler complains about the first const .
(https://stackoverflow.com/questions/21478342/c-const-in-getter
https://arne-mertz.de/2016/07/const-correctness/)
The correct way would be to write

type getValue() const {return value;} 

which does not alter the state of the object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant