有代码:
Date::Date(const char* day, const char* month, const char* year):is_leap__(false)
{
my_day_ = lexical_cast<int>(day);
my_month_ = static_cast<Month>(lexical_cast<int>(month));
/*Have to check month here, other ctor assumes month is correct*/
if (my_month_ < 1 || my_month_ > 12)
{
throw std::exception("Incorrect month.");
}
my_year_ = lexical_cast<int>(year);
if (!check_range_year_(my_year_))
{
throw std::exception("Year out of range.");
}
if (check_leap_year_(my_year_))//SKIPS THIS LINE
{
is_leap__ = true;
}
if (!check_range_day_(my_day_, my_month_))
{
throw std::exception("Day out of range.");
}
}
bool Date::check_leap_year_(int year)const//IF I MARK THIS LINE WITH BREAKPOINT I'M GETTING MSG THAT THERE IS NO EXECUTABLE CODE IS ASSOSIATED WITH THIS LINE
{
if (!(year%400) || (year%100 && !(year%4)))
{
return true;
}
else
{
return false;
}
}
在我看来,这很奇怪。我的代码中有对这个 fnc 的调用,为什么编译器会忽略它。
PS我正在尝试在发布中进行调试。