hello i hardly ever do c++ any more but i answerd a question earlia and been mucking around since then
i got a problem im use to c# and to handle errors its simple
try{whatever and if theres a error it will automaticly go
}
catch{over here}
however c++ not quite same i seem to have to decalare somthing in the catch and use a throw for some reason my point is i got this code (simplified for example)
try{
int x = Convert::ToInt32(this-%26gt;textBox1-%26gt;Text);
int y=Convert::ToInt32(this-%26gt;textBox2-%26gt;Text)...
System::Windows::Forms::MessageBox::Show... =s " + Convert::ToString(x+y),"mkb answer",MessageBoxButtons::OK,MessageBox...
}
catch{}
how can i make it so if theres a error such as some entering a a at the end of a int so theres a add error it just automaticly states in a message box or label error sort thing i know the code for catch like System::windows::forms::messagebox etc just dont seem to work the way im use to doing it in c#
C++ try catch question?
use throw.
assign a character variable.
put input from the textbox into the variable.
check if its number or character
then use throw if character else preceed with that.
for eg.
throw (a)
where a is the character
catch (char a)
parts of a flower
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment