repo.or.cz
/
h2N7SspZmY.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
backup de julho
[h2N7SspZmY.git]
/
data
/
pages
/
languages
/
cpp.txt
blob
076d68554cbb1f18002e5b3b5ad21a6f215414cd
1
====== C++ ======
2
3
[[wp>C++]]
4
5
===== How to use exceptions =====
6
7
<code c++>
8
#include <iostream>
9
using namespace std;
10
11
int f(int x)
12
{
13
if(x < 0) throw 0;
14
return 1;
15
}
16
17
int main()
18
{
19
try {
20
cout << f(0) << endl;
21
cout << f(-1) << endl;
22
} catch(int e) {
23
cout << "catch " << e << endl;
24
}
25
}
26
</code>