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 9 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


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
l l Inheritance Proper Inheritance Multiple Inheritance Public Inheritance should model isa B publicly inherits isa from A This means every object of type B is also an object A of type A anything that is true of an object of A publicisa is also true of an object of B A represents a more general concept B than B B represents a more specialized concept than A anywhere an object of A can be used an object of B can be used Requirements amp Promises of Functions Advertised Requirements PreCondition Advertised Promise Post Condition Expressing Requirement amp Promise Unfortunately in C use Disciplined and Consistent Comments Example void pushint elem class Stack PURPOSE pushes elem onto the top of stack int topO const PURPOSE returns the top element REQUIRE numElemsO 0 PROMISE nothing REQUIRE numElemsO lt 10 PROMISE numElemsO INITIALnumElems l PROMISE topO elem Substitutability Advertised Behavior of the Derived class is Substitutable for that of the Base class Substitutability Derived class Services Require no more and promise no less than the speci cations of the corresponding services in the base class Example int Base fnint X REQUIRE X is Odd int Derivedfn1nt X PROMISE Returns an even int REQUIRE X is int PROMISE Returns 8 Liskov Substitutability PrincipleLSP Any Derived class object must be substitutable Where ever a Base class object is used Without the need for the user to know the difference Inheritance appears Simple class Bird has beak Wings etc public virtual void yO Bird can y class Parrot public Bird Parrot is a bird public virtual void MimicO Can Repeat words Parrot mypet mypetMmicO my pet being a parrot can lLimic mypet y my pet isa bird can y Yes it just appears simple class Penguin public Bird Penguin is Bird This inheritance says that Penguins can y Result of Incorrect understanding from an imprecise language statement Birds can y does not mean all birds can y In general birds that have the ability to y can y Penguins may try to y but will fail Design class Bird has beak Wings etc public v01d PlayWithBird virtual void yO Bird can y Bird y abird class Penguin public Bird Penguin is a Bird abird yO OK if bird PUbh X happens to be virtual void yO error Penguins don t y Parrot Does not model Penguins can t y Eggsnlsfg Models Penguins may y but if they try it is an error Penguin Runtime error if an attempt is made to y not desirable Think about Substitutability Fails LSP Not all birds y Penguins can t Design class Bird has beak Wings etc No y function Birds have beak Wings don t want to say anything about ying here class FlyingBird public Bird A Bird that can y public virtual void yO class NonFlyingBird public Bird A Bird that can t y class Parrot public FlyingBird class Penguin public NonFlyingBird More examples on Inheritance 0 Does class Square inherit from class Rectangle 0 Does class Basket of Bananas inherit from Basket of Fruits Design should be based on Requirements and Requirements The best design depends on What the system is expected to do both now and in the future Multiple Inheritance An object is a kindof more than one type AquaticBeing swim TerrestrialBeing walk Amphibian adopt Ambiguous Functions in Multiple Inheritance TA sam samGoToClassO Student Teacher G T Cl G T Cl OStZdVSO OTCChaSO TA has to overrlde the GoToClass function Sam TA obj ect Student Data Teacher Data TA Data Duplication of Base Class Data in Multiple Inheritance class Window Represents a Window on the Computer class WindowWMenu public Window class WindowWScrollBar public Window class WindowWMenuAndScrollBar public WindowWMenu public WindowWScollBar WindowWMenuAndScrollBar mywindow mywindow Window Data Object WindowWMenu Data Window Data WindowWScrollBar Data WindowWMenuAndScrollBarDat Virtual Base Class class Window Represents a Window on the Computer class WindowWMenu public Virtual Window class WindowWScrollBar public Virtual Window class WindowWMenuAndScrollBar public Virtual Window public Virtual WindowWMenu public Virtual WindowWScollBar WindowWMenuAndScrollBar mywindow mywindow Object Window Data WindowWMenu Data WindowWScrollBar Data WindowWMenuAndS crollBarData Problems With Repetitive Calls to Functions in Multiple Inheritance WindowWMenu drawO Wlndow Windowdraw draw WindowWScrollBar drawO Windowdraw WindOWW WindowWMenuAndScrollBardrawO Menu scro ar WindowWMenudraw draw draWO WindowWScrollBar draWO WindOWWMenu mywindowdrawo Andscro ar Window draw will be called twice draw 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

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

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

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

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.