I was experimenting with the const
keyword and trying to get an useful approach from it.
#include <iostream>
class A
{
public:
static const void modify(float& dummy)
{
dummy = 1.5f;
}
};
int main(int argc, char* argv[])
{
auto a = 49.5f;
A::modify(a);
std::cout << a << std::endl;
return(0);
}
this code compiles and works, the output is 1.5
, I was expecting an error from the compiler because I have a const method that is trying to modify the value of an argument.
What I'm missing here ? How i can design methods that will not modify argument's values?