Click here to Skip to main content
15,891,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,
As in C# i can used excetion as condition like
try
{
 int a=a/0;
}
catch
{
MessageBox("Cant devided by 0");
}


same way i cant get single menthod in vc++(mfc) that work like condition of exception
like if i try
try
{
CStringArray ss;
ss.RemoveAll();
ss.ElementAt(1);        ///ASSERTION GET AT THIS POINT
}
catch
{
AfxMessageBox("Get invalide element");
}
Posted

1 solution

Well, you actually can do that:
try
{
  CStringArray ss;
  ss.RemoveAll();
  ss.ElementAt(1);
}
catch(...)
{
  AfxMessageBox("Get invalid element");
}


You'll get the assertion just with DEBUG build. RELEASE build will not assert.
 
Share this answer
 
v2
Comments
Olivier Levrey 28-Mar-11 9:07am    
Cpallini is right. Assertions are made only in Debug builds. The exception will be thrown in Release builds.
[no name] 29-Mar-11 2:53am    
How i redirect by debug built to realease one.
CPallini 29-Mar-11 3:12am    
To set the RELEASE build, choose 'Build->Configuration Manager' menu item and then set 'Active solution configuration' to 'Release' (at least on VS 2005...).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900