c++代码有错误?

来源:百度知道 编辑:UC知道 时间:2024/06/08 04:21:44
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
MessageBeep(MB_OK) ;
// M e s s a g e B e e p ( M B _ O K ) ;
if(Label1->Caption=="Hello World!"); // 如果显示内容为H e l l o , W o r l d !,
Label1 ->Caption ="世界,你好!"; // 则显示“世界,你好!”
else
Label1->Caption ="Hello World!"; // 否则,显示“H e l l o , W o r l d !”
}

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
MessageBeep(MB_OK) ;
// M e s s a g e B e e p ( M B _ O K ) ;
if(Label1->Caption=="Hello World!"); // 这里错了,IF语句后面不能有;的,要不后面就错了。
Label1 ->Caption ="世界,你好!"; // 则显示“世界,你好!”
else
Label1->Caption ="Hello World!"; // 否则,显示“H e l l o , W o r l d !”
}