CS 162 Lecture Notes - Lecture 7: Member Variable

13 views4 pages

Document Summary

Cs 162 lecture 7 more classes. Review: classes have member variables and functionality, default private. Traditionally member variables are private with member functions being public. Use accessor and mutator functions to work with private member variables: has a constructor. Sets up the object with appropriate values. Is automatically called when the object gets created. If a constructor is not provided by the programmer, one will be automatically generated but will not initialize any values. More details on constructors: must have the same name as the class. Is not allowed to return anything: may have parameters. If no parameters provided, referred to as default constructor. Classes in classes: classes can have other objects. Ex: class line: private, point start_point, end_point; }, classes can be defined in another class but do not do it, calling the constructor of an object in the constructor of the host. Option one: line::line():start_point(1,1), end_point(2,2: have default and single colon, explicitly calling.

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