I have defined a function with default parameter:
void resize(size_t n, std::string &s = std::string()); // error: initial value to non-const must be lvalue
right way:
void resize(size_t n, const std::string &s = std::string());
I want to know why the const
makes a difference?
I know that a const
variable can be assigned an lvalue. Are they the same question?
const int a = 42;