lec0128-params-ann - Today’s announcements: Course...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 12
Background image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Today’s announcements: Course policies: httg://cs.illinois.edu/class/cs225 Email assistance (ews, svn): cs225helg@cs.illinois.edu Sections meet in Siebel 0224, NOT Siebel ARR. MP2 available, due 2/8, 11:59p. EC due 2/1. 11:59p. Proficiency exam: 1/31, 7-10p, Siebel 2407 ->DYB 6-8p tonight. Siebel 1404. TMMR o $'_ Csnfidunecsflhuiswbu Stack vs. Heap memory: void fun() { * String s - “hello!"; cout << 5 << endl; l int main() { funll: return 0: l System allocates space for s and takes care of freeing it when 3 goes out of scope. Data can be accessed directly. rather than via a pointer. All: void fun() l — string = new string; ~ *5 — “he 10?"; cout << '5 << endl: l int main() l fun(); return 0; l Allocated memory must be deleted programmatlcally. Data must be accessed by a pointer. PmiM My shad uslurw W3 class face I —_ public: Pointers and objects: void setName(string n): string getName(): ptxvate: strxng name: — — c—*3cLNamc/“callo=“x; II- l’lk.gelfldmeli: - Ly “A105. c -d~7¢3fiNfin(\) ¥¢ Arrays: st_a_§c (s‘tggfic) “Int h “flu! - Stack memory int x[5]: # XI3]:1') 53;" Lay. >7 5’31;- //’0M “5" ..“t ) M 2.) «aux Arrays: dynamic (heap) alue ‘\lv - m r w - VI. H EIIEIIIE 0' .‘I! w nun-unn- O m e awn]..- w Stack m .u r . m m . :. Z - u .I. i 3 U. o... s z .:. .r 1 L. [ 71 [ I 0! fl 1 0 L X g I _ n _ . m . J .. e 1 .1 H C .U X x w T, .l 1 u. n i e o H — ‘1 . ... f. N * t V. .H ‘ 9... pl _ .1 l n r o e .s ‘1 1 Vs f a! . I w ( X ..t. “ LLWQDV) A point to ponder: How is my in rcien implemented? 4‘388 garderfl Optic . publlc: Mm fit: www- // all the public members . *‘P‘.t.m.) on : prlvate: ——';To—we-r “ plot: 9“ h a a? “frag 4&3 . on o class .9. ftudont ( mfzing name; 3MP mug : ' - - Parameter pass'ng' bool pruned: // p: 1n: (leg ’0 int main“ 1 What happens when we 4tudent a: I) run code like this: pnntawdent 1 6 : - Stack —’ struct student ( string name; . 8MP mug; Parameter passmg: P.” V.“ n bool ptht_:tudcnt1(5tudcnt l 1f (L:.pr1ntcdl cont (6 n.namo '6 ondl: retutn true; ) mm student a;‘F' bool pxxnted: // print (lag Function defn .. // 1n1txallze a Q a.pxl.nted - print_8tudent1 .' a—[ cout << a.pr1ntod << on . leofuse Exam atruct student ( string name; . 8MP mug; Parameter passmg. bool mated; H pm! flag 1 .E void pxxnt_:tuv1cnt;Afstujcnt ‘ 3n: (“c-tn «1 «~' bra-1L: sammc : ’sun S-fifflnfid : T} 3 student ° b; '8 .. // 1n1t1a112e b 0 . a print student: Q: E Gout <‘*Y).prinf <'<‘ and}; at ruct student ( string name; . 8MP mug: Paramete pass'ng: bool prxnted; // pxlnt (leg 91“ f once / H void prxnt_:tudcnt3 (stuzcnt 8 all d 12' cj‘. J.pr1ntcd} cour c'c' .1.n.1mr~ c'c ondl; . - Mb Sfmfil- Function defn g student c; 8 ~ 9 .. // xnxtxalue c % p:1nt_atudent3 (3!; 2 cout <f< c.printed <‘<' endl; m LT Function defn Example of use ottuct otu ( string a: m "a: Parameter passing summary: “,1 W ,, Punt m, H boo]. pll(ltu 3H void p.2(ltu ' I)! void p.3(ltu 5 I)! it (El.pt) 1: (ll->pt) it (El.pt) cout << 0.0: cout << c->n: cout << IAN: return true: I->pt - true; I.pt - true: P t D Itu a: ltu " b: Itu c: .. // intt a .. // init 'b .. ll init c mp: - pol“): p020»: pa3tc); cout << 04):: cout << b->pt: cout << c.pt: Today‘s new learning: 1. pass by value 2. pass pointer by value 3. pass by reference Today’s review and extension: 1. flower “ plot; Today's assignment for independent learning: 1. reference variables: http://www.cprogramming.com/tutorial/references.html ...
View Full Document

Page1 / 13

lec0128-params-ann - Today’s announcements: Course...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online