CS246 Lecture Notes - Lecture 16: In C

40 views6 pages

Document Summary

E. g. int negint(int i) { return -i; bool negbool(bool b) { return !b; Instead, int neg(int i) { return -i; bool neg(bool b) { return !b; The compiler will use the # and type of parameters to pick the right function to call. Overloads must differ in either the # or type of some parameters. Cannot overload based on return type (having same input but different output) In c++, we must declare something before we can use it. Declaration: only asserts the existence of a entity. (forward declaration) Definition: full definition, including allocation of space if needed. An entity can be declared multiple times but defined only once. Arrays int a[] = {1,2,4,8}; // the name of the array is just shorthand for the. Constant provides mechanism to ensure a variable"s value cannot be changed. Node mynode = {5, null}; const node cn = mynode; What does const int *p = &n mean? (int n)

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