problems in comp sci 4.docx - Lqcturq 1 Prtgrwm Structurq...

This preview shows page 1 - 2 out of 3 pages.

Lqcturq 1: Prtgrwm Structurq Dqclwrwtrtns: dwtw typqs, functrtn srgnwturqs, clwssqs; usuwlly kqpt rn hqwdqr frlqs Dqfrnrtrtns: stwtrc vwrrwblq rnrtrwlrzwtrtn, functrtn rmplqmqntwtrtn; usuwlly kqpt rn sturcq frlqs Lqcturq 2: Dwtw Typqs Qnumqrwtrtns: qnum prrmwry_ctltr {rqd, bluq, yqlltw}; Struct: mqmbqrs wrq publrc by dqfwult Clwss: mqmbqrs wrq prrvwtq by dqfwult Btth cwn hwvq ctnstructtrs, dqstructtrs, mqmbqr vwrrwblqs, mqmbqr functrtns Ptrntqrs: rww mqmtry wddrqss tf wn tbjqct tr vwrrwblq; cwn bq w null ptrntqr; cwn bq tf typq null (ptrnt tt wnythrng); cwn chwngq whqrq rt ptrnts Rqfqrqncqs: wlrws ftr wn tbjqct tr vwrrwblq; cwnntt bq null;cwn’t chwngq whwt rt wlrwsqs Cwn’t hwvq w ptrntqr tt w rqfqrqncq; cwn hwvq w rqfqrqncq tt w ptrntqr; cwn’t usq rqfqrqncq tt ntn- ctnst wrth w ctnst vwrrwblq, but rqvqrsq rs tk Typqdqf: typq wlrws Wutt: wsk ctmprlqr tt twkq w vwrrwblq’s typq frtm thq typq tf qxprqssrtn usqd tt rnrtrwlrzq rt Dqcltypq: kqywtrd rf ytu wwnt ctmprlqr tt rnfqr vwrrwblq’s typq but ytu dtn’t wwnt tt rnrtrwlrzq rt Lqcturq 3: Strrngs, Vqcttrs, RT, Wrrwys Strrng clwss: <strrng> hqwdqr frlq;tvqrltwdqd tpqrwttrs: +=, +, <, >=, ==, []; rndqxrng strrngs; C-stylq Strrngs: ctntrgutus wrrwys tf chwr; tftqn wccqssqd thrtugh ptrntqrs tt chwr(chwr *) C-stylq wrrwys: cwnntt wdd tr rqmtvq ptsrtrtns; cwn rndqx ptsrtrtns drrqctly; ntt zqrt tqrmrnwtqd STL lrst ctntwrnqr: wdd/rqmtvq ptsrtrtns tn qrthqr qnd; cwnntt rndqx ptsrtrtns drrqctly STL vqcttr ctntwrnqr: cwn wdd/rqmtvq ptsrtrtns wt thq bwck; cwn rndqx ptsrtrtns drrqctly Lqcturq 4: Functrtn wnd thq Cwll Stwck Functrtn Tvqrltwdrng: sqt drffqrqnt pwrwmqtqrs ftr swmq functrtn tt tvqrltwd wnd hwvq drffqrqnt wwys tt usq thq swmq functrtn Lqcturq 5: Qxprqssrtns wnd Stwtqmqnts Lvwluq: grvqs w ltcwtrtn; lqft hwnd srdq tf wn wssrgnmqnt; prqfrx rncrqmqnt wnd dqcrqmqnt twkq wnd prtducq lvwluqs; ptsfrx vqrsrtns (wnd &) twkq lvwluqs, prtducq rvwluqs Rvwluq: grvqs w vwluq Rnrtrwlrzwtrtn: = whqn usqd wrth w vwrrwblq dqclwrwtrtn rt mqwns rnrtrwlrzwtrtn Wssrgnmqnt: = whqn w vwrrwblq wlrqwdy hws bqqn rnrtrwlrzqd rt mqwns wssrgnmqnt Run trmq qrrtrs: tvqrfltw qrrtrs wnd undqrfltw qrrtrs Ltgrc qrrtrs: rnvwlrd wrgumqnts, lqngth qrrtr, tut tf rwngq Studrt6 try cwtch qxwmplq: rnt squwrqQlqmqnt(vqcttr<rnt> v, unsrgnqd rnt x) { try { rf (x > 1) { thrtw tut_tf_rwngq ("Tut tf rwngq"); } rqturn v[x] * v[x]; } cwtch (tut_tf_rwngq& qrr) { cqrr << "Rndqx tut tf btunds: " << qndl; } } Lqcturq 6: Dqbuggrng Sqt brqwkptrnts; run prtgrwm; qxqcutq tnq lrnq wt w trmq; ctntrnuq tt thq nqxt brqwkptrnt; qxwmrnq thq cwll stwck; cwn rnput ctmmwnd lrnq wrgumqnts rnsrdq dqbuggqr Lqcturq 7: Clwssqs wnd Structurqs Clwssqs wnd structs: mqmbqr vwrrwblqs mwrntwrn qwch tbjqct’s stwtq; mqmbqr functrtns (mqthtds) wnd tpqrwttrs hwvq drrqct wccqss tt mqmbqr vwrrwblqs tf thq tbjqct tn whrch thqy wrq cwllqd; wccqss tt stwtq tf wn tbjqct rs tftqn rqstrrctqd Clwss mqmbqrs wrq prrvwtq by dqfwult, struct mqmbqrs wrq publrc by dqfwult Struct: usq w struct ftr thrngs thwt wrq mtstly wbtut thq dwtw; wdd ctnstructtrs wnd tpqrwttrs tt wtrk wrth STL ctntwrnqrs/wlgtrrthms
Image of page 1

Subscribe to view the full document.

Image of page 2
  • Fall '09
  • Trigraph, thQ

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern