Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78976089
exception.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 24, 02:13
Size
498 B
Mime Type
text/x-c
Expires
Mon, Aug 26, 02:13 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
20130449
Attached To
R9360 PCSC_git
exception.cpp
View Options
#include <cmath>
#include <iostream>
#include <string>
struct
Exception
{
Exception
(
const
std
::
string
&
mesg
)
:
mesg
(
mesg
){};
const
std
::
string
&
what
()
{
return
mesg
;
};
std
::
string
mesg
;
};
double
mysqrt
(
double
x
)
{
if
(
x
<
0
)
{
throw
Exception
(
"no negative number sqrt"
);
}
return
std
::
sqrt
(
x
);
}
int
main
(
int
argc
,
char
**
argv
)
{
try
{
double
res
=
mysqrt
(
-
1
);
std
::
cout
<<
res
<<
std
::
endl
;
}
catch
(
Exception
&
e
)
{
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
}
}
Event Timeline
Log In to Comment