CS 225 Lecture Notes - Lecture 10: Pom-Pom

24 views2 pages

Document Summary

// general class, called the base class class sphere { public: sphere(); sphere(double r); double getvolume(); void setradius(double r); void display(); private: double theradius. // more specific class, called the derived class. // if we use public sphere, we can also use private or protected. class ball:public sphere { // public denotes an inheritance type, not access type public: // whereas here it"s an access type ball(); ball(double r, string n); string getname(string n); void setname(string n); void display(); private: string name; // everything public to ball is public to sphere, so if we do: ball b; b. setradius; Inheritance rules: for derived class objects: base access + inheritance type, determines derived access, meaning the most restrictive applies, base class private are not accessible. // protected type: it"s like private to the client, but public to derived class members have access. // if a class is derived from a derived class, the newly derived class inherits.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents