CSE 100 Lecture Notes - Lecture 28: Calcareous Sponge
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.