static ints, compilation units and the ternary operator
问题 // SomeCls.h class SomeCls { static const int PERIOD_ALARM_NORMAL = 5; static const int PERIOD_ALARM_THRESH = 1; void method() { bool b = true; const int d = b ? PERIOD_ALARM_THRESH : PERIOD_ALARM_NORMAL; } } obj; It is going to build ok. Now take out the method() implementation and place it in a cpp file: //SomeCls.cpp #include "SomeCls.h" void SomeCls::method() { bool b = true; const int d = b ? PERIOD_ALARM_THRESH : PERIOD_ALARM_NORMAL; } Why does mr. linker say undefined reference to