topical media & game development
professional-program-15-StackUnwinding-SmartPointer.c
? /
professional-program-15-StackUnwinding-SmartPointer.c
include <fstream>
include <iostream>
include <stdexcept>
using namespace std;
void funcOne() throw(exception);
void funcTwo() throw(exception);
int main(int argc, char** argv)
{
try {
funcOne();
} catch (exception& e) {
cerr << "Exception caught!\n";
exit(1);
}
return (0);
}
include <memory>
using namespace std;
void funcOne() throw(exception)
{
string str1;
auto_ptr<string> str2(new string("hello"));
funcTwo();
}
void funcTwo() throw(exception)
{
ifstream istr;
istr.open("filename");
throw exception();
istr.close();
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.