CS 225 Lecture 3: Constructors and Scope Res

26 views4 pages

Document Summary

Daily exercises start at 8/29: 8am it will be on prairie learn. // continuation from previous lecture int main() { sphere b; // we can use b like this, accessing member functions b. setradius(1. 2); cout << b. getdiameter(); // cout << b. theradius; we can"t do this because it"s a private class. // the reason is so clients can"t do this: b. theradius = -8. 25. // we"re going to set up the member function setradius in a way that clients can"t set up negative radius. // we don"t need to expose the implimitation when using setradius and get. // :: scope resolution operator, a key symbol defined in c++ to resolve/determine scope. // it"s so we know we"re accessing the sphere function. // main. cpp is the file that contains the client code. // any function that is scoped to the sphere class can access private variables and functions.

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