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 2


Class Note for COSC 1320 at UH 2

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

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 8 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 14 views.

Similar to Course at UH


Reviews for Class Note for COSC 1320 at UH 2


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
Example of Writing a Constructor class Switch In the Switchh le public SwitchO Declaration of a Constructor for the Switch class void turnOn private bool position In the Switchcpp le SwitchSwitch Implementation of the Constructor position true Writing Constructors class Date Dateint rmonth int rday int ryear Say this is only constructor for Date Date xmas12 25 1996 samsdob010182 Date bobsdob Error can t create without more info Several Ways to Initialize an Object Five Constructors for Date Class Dateint rm int rd int ry month day year Date int int month day This year Date int month This year amp day DateO39 Initialize to today Dateconst char39 In the form June 10 1996 061096 etc Five Ways to Create a Date Object Date dobl l 1996 Calls Date int int int Date christmas12 25 christmas 96 Date newyearsdayl39 Jan l 1996 Date today Date july4 July 4 1996 How about Todays Date Date vacationstartdate today 7 Initializing one Object Using Another String str2 strl String strl Hello astring foostrl strlget fooconst Stringamp astring String str2 astring5 str2set Surprise BitWisecopy str Hello str Deep vs Shallow Copy Copy Constructor Ensures Proper Initialization of an Object 0 Of the form Xconst Xamp StringStringconst Stringamp otherobj str new char strlenotherobjstr l strcpystr otherobjstr String str2 astring aString str str2 str Invocation of a Copy Constructor 0 A Copy constructor is called Whenever a copy of an object is made 0 Is called when you create an object using another object of same type String strl Hello Does not call Copy constructor String str2 strl Calls copy construcytor 0 When you call a function with an argument by value void functionlString stringObj J A call to functionl results in a call to copy constructor Scope Automatic Variables amp Free Store 0 Scope of Objects in C Blocks functions 0 Automatic Variables Free Store Management new and delete Garbage Collection amp Destructor Cleaning Up when an Object is no longer needed Automating some routine final processing tasks class FileHandler filehandle int openconst charquotlt lename void close FileHandler close Destructor followed by the class name 0 No arguments No return value Only one allowed per class class String String delete str Destructor for String Class Invocation of Destructor You do not call the destructor When ever an automatic variable goes out of scope destructor is called String strObj Hello strObj goes out of scope here Its destructor is called When ever an object on the heap is deleted by you String ptr new String Whats up delete ptr Destructor of String is called here Should I write a Destructor for my classquot 0 Generally you do not need a destructor if your class does not use pointers 0 If you class has pointer to another object or data that must be deleted when your object is destroyed then you must write a destructor 0 Later we will discuss Law Of Big Three struct amp class in C 0 class amp struct both represent a class in C 0 class provides private access rights by default 0 struct provides public access rights by default 0 classes are usually used to represent Classes 0 struct used to represent data usually local Lab Work Details provided online 3 Classes Construction amp Destruction Constructors Object Initialization Guarantees that an object is in a valid state upon creation Constructor is automatically called when an object is created 0 Constructor has the same name as the Class 0 No return value


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

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

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.