Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exception handling

0 views
Skip to first unread message

d2002xx

unread,
Sep 27, 2002, 4:36:59 AM9/27/02
to
※ 引述《hacpe...@bbs.kimo.com.tw (到什麼時候ㄋ??)》之銘言:
> 在C++ prime中文版中 P.559
> int a=100 ;
> try
> {
> throw a;
> }
> catch(int& a)
> {
> a=1000;
> }
> printf("%d",a);
> 結果: 100
> 為什麼我已經宣告reference
> 卻仍然無法改變 a 的值呢?

Use this:

//////////////////////////
try {
throw &a;
}
catch(int* ap) {
*ap = 1000;
}
//////////////////////////

Why not learn Java instead?? It's far simpler.
--
[1;32m※ Origin: [33m台灣科大電子站 [37m<bbs.et.ntust.edu.tw> [m
[1;31m◆ From: [36m61.70.221.93 [m

0 new messages