COMPTNG 10A- Final Exam Guide - Comprehensive Notes for the exam ( 47 pages long!)

84 views47 pages
30 Nov 2017
School
Professor

Document Summary

Tell the reader of the code that you do not intend to change this variable. Const double: stop from changing element of the array. Const d_arr: prevents pointer to pointing to another place. When you pass by copy = spend time copying = wasteful. Pass (cid:271)y refere(cid:374)(cid:272)e = do(cid:374)"t spe(cid:374)d ti(cid:373)e (cid:272)opyi(cid:374)g: however is unsafe because actual inputs can be modified. Solution = use const reference input for both speed and safety: = do(cid:374)"t spe(cid:374)d ti(cid:373)e (cid:272)opyi(cid:374)g a(cid:374)d (cid:449)e are safe, example: const string& s. Allowed to have function signature mismatch between the definition and declaration. De(cid:272)laratio(cid:374) does(cid:374)"t (cid:374)eed (cid:272)o(cid:374)st (cid:449)he(cid:374) defi(cid:374)itio(cid:374) has. You also do(cid:374)"t (cid:374)eed (cid:448)aria(cid:271)le (cid:374)a(cid:373)es i(cid:374) declaring function signatures when the definition has a name. When trying to return objects/members from a const class, member function needs to be const too so the compiler knows that the member is also not changed. Operator functions like ==, +, -, != should be const.

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

Related Documents