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/12/29 19:42:40
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 我给的答案对不对啊