Код: Выделить всё
template
void foo(const T & a) { /* code */ }
// This would also fail
// void foo(const int & a) { /* code */ }
class Bar
{
public:
static const int kConst = 1;
void func()
{
foo(kConst); // This is the important line
}
};
int main()
{
Bar b;
b.func();
}
Код: Выделить всё
Undefined reference to 'Bar::kConst'
Код: Выделить всё
foo(static_cast(kConst));
Мне интересно, было ли это сделано намеренно или я ожидаю слишком многого от gcc, чтобы справиться с этим случаем? Или мне по какой-то причине не следует этого делать?
Подробнее здесь: https://stackoverflow.com/questions/539 ... -const-int