New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

C++ Programming

by: Jean Dach

C++ Programming CS 256

Jean Dach
CSU Pomona
GPA 3.57

David Gershman

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

David Gershman
Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 3 page Class Notes was uploaded by Jean Dach on Saturday October 3, 2015. The Class Notes belongs to CS 256 at California State Polytechnic University taught by David Gershman in Fall. Since its upload, it has received 12 views. For similar materials see /class/218305/cs-256-california-state-polytechnic-university in ComputerScienence at California State Polytechnic University.

Similar to CS 256 at CSU Pomona

Popular in ComputerScienence


Reviews for C++ Programming


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/03/15
Lecture 2011703709 7 Exceptions 7 Exceptions are special cases where the code fails to perform and the programmer didn39t put special handling routines in place 7 When an exception arises it39s called quotThrowingquot the exception 7 Uses the keyword 39Throw39 ex void amethod int x if lt 0 ll x gt 100 throw quotInvalid valuequot 7 Special C construct called quotException Handlerquot is used to quotcatchquot thrown exceptions39 tr amethod 4 amethod amethod l Never executed 75 2 catch char errormsg r lt7777 parameters cout ltlt quotEr or quot ltlt errormsg 7 As long as no exception thrown block execution continues as normal in the quottry Once control is passed to the quotcatchquot block the rest of the code in the quottryquot block is skipped 7 If no thrown exceptions quotcatchquot block is skipped 7 Can throw exceptions of any type void amethod long Y i if y lt 0 throw 1 ifygtl00 th row 2 cout ltlt y ltlt quot is a good valuequot ry amethod 76 catch int e lt7777 parameters if cout ltlt quotOnly positive values allowedquot if e 2 77 cout ltlt quotValue must be 100 or lessquot If not 39throw39s execution continues here 7 Exceptions can also be classes class posnum private 39 t x public class MyError Empty class but can be used with 39throw39 posnum set int l posnumposnum x l posnumset int x if x lt 0 throw MyError this 7gt x x l Can now use the class int main posnum P Pset 7100 Will terminate program ex2 int main posnum P try Pset 7100 catch posnumMyError cout ltlt quotWrong Valuelquot 7 Can even pass ValueSparams to exception classes class posnum private int x public class MyError private39 MyError int v getvalue return Value posnum set int posnumposnum x 0 l posnumset int x if x lt 0 throw MyError X this 7gt x 7 x Can now use the class int main posnum P try Pset 7100 catch posnumMyError e cout ltlt quotWrong value quot ltlt egetvalue ltlt endl l 7 If you don39t want to handle the exception you can also quotrethrowquot it int main posnum P try Pset 7100 catch posnumMyError e throw l 7 Multiple exceptions are handled with multiple exception classes Then int main posnum P try Pset 7100 catch posnumMyErrorTypel e cout ltlt quotValue to bigquot catch posnumMyErrorType2 throw Choose not to handle this type of error 7 Exercises to answer 1 Can code be placed in between 39catch39 blocks Answer No ex try some code here catch l l more code here catch l 2 Does empty parameters on 39catch39 catch everything Answer Empty e not allowed must specify a typ 3 What prints out if the exception is not handled Answer The exception type and 39Aborted39 disclaimer at least on Linux


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Janice Dongeun University of Washington

"I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.