vc++中try,catch,throw怎么不对了?我写了这样的代码 try {if(this->textBox1 ->Text ==" "||this->textBox2 ->Text ==" ") throw "a";}catch (char ){this->label4->Text ="数据输入错误";};int a,b,c;a=Convert::ToInt32 (this->textBox1->Text );
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/21 06:04:15
![vc++中try,catch,throw怎么不对了?我写了这样的代码 try {if(this->textBox1 ->Text ==](/uploads/image/z/9491412-12-2.jpg?t=vc%2B%2B%E4%B8%ADtry%2Ccatch%2Cthrow%E6%80%8E%E4%B9%88%E4%B8%8D%E5%AF%B9%E4%BA%86%3F%E6%88%91%E5%86%99%E4%BA%86%E8%BF%99%E6%A0%B7%E7%9A%84%E4%BB%A3%E7%A0%81+try+%7Bif%28this-%3EtextBox1+-%3EText+%3D%3D%22+%22%7C%7Cthis-%3EtextBox2+-%3EText+%3D%3D%22+%22%29+throw+%22a%22%3B%7Dcatch+%28char+%29%7Bthis-%3Elabel4-%3EText+%3D%22%E6%95%B0%E6%8D%AE%E8%BE%93%E5%85%A5%E9%94%99%E8%AF%AF%22%3B%7D%3Bint+a%2Cb%2Cc%3Ba%3DConvert%3A%3AToInt32+%28this-%3EtextBox1-%3EText+%29%3B)
vc++中try,catch,throw怎么不对了?我写了这样的代码 try {if(this->textBox1 ->Text ==" "||this->textBox2 ->Text ==" ") throw "a";}catch (char ){this->label4->Text ="数据输入错误";};int a,b,c;a=Convert::ToInt32 (this->textBox1->Text );
vc++中try,catch,throw怎么不对了?
我写了这样的代码
try {if(this->textBox1 ->Text ==" "||this->textBox2 ->Text ==" ") throw "a";}
catch (char ){this->label4->Text ="数据输入错误";};
int a,b,c;
a=Convert::ToInt32 (this->textBox1->Text );
b=Convert::ToInt32 (this->textBox2->Text) ;
c=a+b;
for(c=1;c%b!=0||c%a!=0;c++);
this->label4->Text =this->textBox1 ->Text +"和"+this->textBox2 ->Text +"的最小公倍数是:"+ Convert::ToString (c);
在编译时可以通过,但是输入空格时,它不能正确处理异常啊,这是为什么啊?
不要只是评价啊,要的是解决的办法,就是不懂才问啊
vc++中try,catch,throw怎么不对了?我写了这样的代码 try {if(this->textBox1 ->Text ==" "||this->textBox2 ->Text ==" ") throw "a";}catch (char ){this->label4->Text ="数据输入错误";};int a,b,c;a=Convert::ToInt32 (this->textBox1->Text );
try
{
if(!strcmp(" ",this->textBox1 ->Text)
|| !strcmp(" ",this->textBox2 ->Text))
throw "a";
}
catch (char* )
{
this->label4->Text ="数据输入错误";
AfxMessageBox("数据输入错误");
};
补充:
请问一下 silvergingko 我给的答案对不对啊