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

Class Note for COSC 1320 at UH


Class Note for COSC 1320 at UH

Marketplace > University of Houston > Class Note for COSC 1320 at UH

No professor available

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

No professor available
Class Notes
25 ?




Popular in Course

Popular in Department

This 7 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Houston taught by a professor in Fall. Since its upload, it has received 12 views.

Similar to Course at UH


Reviews for Class Note for COSC 1320 at UH


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: 02/06/15
6 Overloading Functions Inlz39m39ng etc Function Overloading Notational convenience for functions that perform the same task on objects of different types void print int a void print double b void print char c void print double a double b Overloaded functions must have different argument signature ie types andor ordering of arguments Name resolution Argument Matching Exact match with no or unavoidable conversion int to const int 0 Matching using integral promotions short to int 0 Matching using standard conversions int to double 0 Matching using userde ned conversions Lets match the calls to functions in the print example pIint1 p1intl2 37 pIint a printl 2 3 p1int12 print2 3 Constructors as Overloaded Functions class Complex double re double im public Complex double rep double imp Complex double rep imp is assumed 0 Complex const Complexamp obj Copy constructor Complex 0162 81 Complex 0228 Complex 038 Complex c422 4 Complex 0504 Matching userdefined Conversion void print int a void print double b void print char c void print double a double b void print Complex a Lets match the calls to functions in the print example printl printl 2 37 print a printl 2 3 printl 2 printc3 Functions With Default Arguments Complex may be created with real and imaginary values or just with real value and an assumed 0 for the imaginary value Using overloading Complex double rep double imp Complex double rep Using default argument Complex double rep double imp 0 double powerdouble value int pwr2 Compute valuePWT if pwr not given compute value2 power3 3 27 power3 2 9 power3 9 Rule for Default Arguments 0 Default Arguments must be trailing void fooint a 0 int b int c 5 Error Example void computeint i l intj 2 int k 3 Effective values of arguments i j k in the following compute3 4 5 compute3 4 3 4 5 3 4 3 compute3 compute 323 123 Avoiding CStyle Macros Macros were used to help coding define MAX 1000 Problems with macros Textual replacement Preprocessor handles it 0 No precedenceType checks define SQUARE X X X SQUARE 2 3 Surprisell Encapsulation amp Performance inlining functions Function Call Overhead mywatchReset Calls a function to set seconds to 0 Functions may be inline d to avoid function call overhead Expands the function Where called Done by the compiler not preprocessor Checks for types and precedence rules are enforced Writing an Inline function 0 If function is defined Within the class it is considered inline 0 If function is defined outside the class specify inline explicitly class StopWatch long getSecondsO return seconds Inline since defined Within class inline void Reset Inline since speci ed void start Not inline Inline Functions Usage inline not an order request honored if function is small a few lines in size function is nonrecursive The code for the function should be available to the compiler for expanding on call This requires that the function be placed in the header file in case of class member inline functions not so desirable Suggestion worry about inlining functions when nearing release only advantage is performance Ellipsis Function with unspecified of arguments Provides flexibility to pass variable of arguments void sortint number Sort variable of ints Sacrifice one of the best features of C strong type checking Implemented using valist structure Don t even think about it Only prudent use catching arbitrary exceptions Lab Work Details provided online


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!"

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."


"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.