/************************************************************************** * * Language: C++ * Purpose: Program to demonstrate the 'try', 'catch' and 'throw' statements. * Author: M J Leslie * Date: 21-Mar-98 * * Compile: The following command was used to compile. * * g++ -fhandle-exceptions throw.cc -o throw * **************************************************************************/ #include <iostream.h> // For cout. void ErrorFunc(int Error); main() { ErrorFunc(0); ErrorFunc(1); } void ErrorFunc(int Error) { try { cout << "Error code is " << Error << endl; if (Error > 0 ) { throw(Error); // This statement causes control to jump // to the 'catch' statement } cout << "No Error occoured" << endl; } catch(int n) { cout << "Error number is " << n << endl;; } }
file: /Techref/language/ccpp/cppref/examples/throw.cc, 0KB, , updated: 1998/3/21 15:56, local time: 2025/5/2 16:59,
18.116.62.169:LOG IN
|
©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.piclist.com/techref/language/ccpp/cppref/examples/throw.cc"> language ccpp cppref examples throw</A> |
Did you find what you needed? |
![]() o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
The Backwoods Guide to Computer Lingo |
.