Re: [問題] 條件運算子
來用C++的方法吧,answer要是編譯期常數喔~
template<int N>
struct EQ_7
{
int operator()(int d)
{ return ++d; }
};
template<>
struct EQ_7<7>
{
int operator()(int d)
{ return --d; }
};
int main()
{
cout<<EQ_7<7>()(10)<<endl;
cout<<EQ_7<8>()(10)<<endl;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.39.34.40
→
02/11 22:02, , 1F
02/11 22:02, 1F
→
02/14 12:53, , 2F
02/14 12:53, 2F
討論串 (同標題文章)