确定好我有结构C++结构和const
struct balls {
balls(UINT_PTR const &val) : BALL_ID(val){}
int Ex;
int Ey;
const UINT_PTR BALL_ID;
};
balls ball1(0x1);
和我有一个switch语句
switch(wParam)
{
case ball1.BALL_ID:
if(ball1.Ex<300)
{
ball1.Ex++;
}
else
{
KillTimer(hWnd, ball1.BALL_ID);
}
InvalidateRect(hWnd, rect, false);
break;
case SCORECOUNTER_ID:
if(life==0)
{
if(scorecounter<1000)
{
scorecounter+=100;
_swprintf(str, _T("Score: %d"), scorecounter);
InvalidateRect(hWnd, rect, false);
}
else
{
_swprintf(level, _T("Level: %d"), 2);
InvalidateRect(hWnd, rect, false);
}
}
break;
}
我得到一个错误thatball1.BALL_ID不是恒定的第二行应该解决了这一点,但它没有任何想法?
那么我该如何解决它? – Ramilol 2010-08-17 08:10:01
使用if(),可能。 – 2010-08-17 08:15:36
...为什么当然是,除非OP需要坚持'switch'! – dirkgently 2010-08-17 08:17:43