I am reading "C++17 The Complete Guide" by Nicolai Josuttis, and I didn't understand the following: why in C++14 following code is not working
struct D
{
static constexpr int n = 5;
};
int inc(const int& n)
{
return n;
}
int main()
{
std::cout << inc(D::n) << std::endl;
}
returning following error
main.cpp:(.text+0x15): undefined reference to `D::n'
while this other
struct D
{
static constexpr int n = 5;
};
int main()
{
std::cout << D::n << std::endl;
}
is perfectly fine?