What does const at the end of a class member function declaration mean in C++?
Hi everyone! I started learning C++ after Python and Java, and I came across some unclear syntax. In other people's code, I often see the keyword `const` after a class member function declaration. For example:
```cpp
class MyClass {
public:
int getValue() const; // This const at the end
void setValue(int v);
};
```
I understand that `const` before a variable means the variable cannot be changed. But what does `const` *after* the parameter list mean? I tried writing without it — the compiler doesn't complain. So why is it needed? Does it affect how I can call the function? Can I put it on any function? Or only on getters?
I wrote a simple class:
```cpp
class Counter {
public:
Counter() : count(0) {}
int getCount() const { return count; } // Works