Double bookshipping double audiobookprice derived

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: selfassignment if(&rhs != this) { title=rhs.title; year=rhs.year; } return *this; } AudioBook& AudioBook::operator= (const AudioBook& rhs) { //check for selfassignment if(&rhs != this) { Book::operator=(rhs); length=rhs.length; } return *this; } 2 10/9/12 Derived Class Added Func/ons •  Derived Class can add new member func/ons: double AudioBook::length_v (); •  Derived Class can override func/ons in the based class. double Book::shipping(); double AudioBook::price (); •  Derived Class can overload func/ons in the Base class: void Book::update (string); void Book::update (int); void AudioBook::update (double); Exercise int main() Func/on called: { Book::Book(string,int) Book a("C", 1990); AudioBook b; AudioBook c("JavaScript",2008,1.5); AudioBook d(c); a=c; //ok, information lost a.update(1990); b=a; //error c.update(“C++”); a.shipping(); b.sipping(); d.update(3.5); } Sta/c Binding •  Both Overloading and overriding func/ons have the same name. •  Depending on the class type of the...
View Full Document

This document was uploaded on 03/06/2014 for the course CS 3710 at Memorial University.

Ask a homework question - tutors are online