Δημοσιεύτηκε: 04 Μάιος 2009, 10:20
Το βρήκα στο google. Είναι ωραίο παραδειγματάκι.
http://www.gotw.ca/gotw/066.htm
Αν σε βοήθησε το link βάλε ένα τικ στο τίτλο. Γενικά ένασε forum για Java. Θα μπορούσαν να σε βοηθήσουν καλύτερα.
- Κώδικας: Επιλογή όλων
// Example 1(a): Constructor function-try-block
//
C::C()
try
: A ( /*...*/ ) // optional initialization list
, b_( /*...*/ )
{// Example 1(a): Constructor function-try-block
//
C::C()
try
: A ( /*...*/ ) // optional initialization list
, b_( /*...*/ )
{
}
catch( ... )
{
// We get here if either A::A() or B::B() throws.
// If A::A() succeeds and then B::B() throws, the
// language guarantees that A::~A() will be called
// to destroy the already-created A base subobject
// before control reaches this catch block.
}
}
catch( ... )
{
// We get here if either A::A() or B::B() throws.
// If A::A() succeeds and then B::B() throws, the
// language guarantees that A::~A() will be called
// to destroy the already-created A base subobject
// before control reaches this catch block.
}
http://www.gotw.ca/gotw/066.htm
Αν σε βοήθησε το link βάλε ένα τικ στο τίτλο. Γενικά ένασε forum για Java. Θα μπορούσαν να σε βοηθήσουν καλύτερα.