Skip to content

Compiler errors about const specifier in getter functions #127

@tonimueller

Description

@tonimueller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions