CSE 100 Lecture Notes - Lecture 28: Calcareous Sponge

52 views3 pages

Document Summary

A class object can be passed as an argument to a function. When it is passed by value, the function makes a local copy of the object. The original object in calling environment is unaffected by actions in the function. When passed by reference, the function can set" functions to modify the function in the calling environment. Using a value parameter for an object can slow down a program and waste space. Using a reference parameter speeds up the program. It allows the function to modify data in the parameter, which may not be desirable. To save space and time while protecting parameter data that should not be changed, use a const reference parameter. In order for the showdata function to call square member functions, those functions must use const in their prototype and header: Cout << enter the length of side: //declare setter and getter functions using prototype. //function to calculate the area of the triangle.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents