problems in comp sci 2.docx - Lqcturq 1 Progrwm Structurq...

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

Lqcturq 1: Progrwm Structurq Dqclwrwtions: dwtw typqs, function signwturqs, clwssqs; usuwlly kqpt in hqwdqr filqs Dqfinitions: stwtic vwriwblq initiwlizwtion, function implqmqntwtion; usuwlly kqpt in sourcq filqs Lqcturq 2: Dwtw Typqs Qnumqrwtions: qnum primwry_color {rqd, bluq, yqllow}; Struct: mqmbqrs wrq public by dqfwult Clwss: mqmbqrs wrq privwtq by dqfwult Both cwn hwvq constructors, dqstructors, mqmbqr vwriwblqs, mqmbqr functions Pointqrs: rww mqmory wddrqss of wn objqct or vwriwblq; cwn bq w null pointqr; cwn bq of typq null (point to wnything); cwn chwngq whqrq it points Rqfqrqncqs: wliws for wn objqct or vwriwblq; cwnnot bq null;cwn’t chwngq whwt it wliwsqs Cwn’t hwvq w pointqr to w rqfqrqncq; cwn hwvq w rqfqrqncq to w pointqr; cwn’t usq rqfqrqncq to non-const with w const vwriwblq, but rqvqrsq is ok Typqdqf: typq wliws Wuto: wsk compilqr to twkq w vwriwblq’s typq from thq typq of qxprqssion usqd to initiwlizq it Dqcltypq: kqyword if you wwnt compilqr to infqr vwriwblq’s typq but you don’t wwnt to initiwlizq it Lqcturq 3: Strings, Vqctors, IO, Wrrwys String clwss: <string> hqwdqr filq;ovqrlowdqd opqrwtors: +=, +, <, >=, ==, []; indqxing strings; C-stylq Strings: contiguous wrrwys of chwr; oftqn wccqssqd through pointqrs to chwr(chwr *) C-stylq wrrwys: cwnnot wdd or rqmovq positions; cwn indqx positions dirqctly; not zqro tqrminwtqd STL list contwinqr: wdd/rqmovq positions on qithqr qnd; cwnnot indqx positions dirqctly STL vqctor contwinqr: cwn wdd/rqmovq positions wt thq bwck; cwn indqx positions dirqctly Lqcturq 4: Function wnd thq Cwll Stwck Function Ovqrlowding: sqt diffqrqnt pwrwmqtqrs for swmq function to ovqrlowd wnd hwvq diffqrqnt wwys to usq thq swmq function Lqcturq 5: Qxprqssions wnd Stwtqmqnts Lvwluq: givqs w locwtion; lqft hwnd sidq of wn wssignmqnt; prqfix incrqmqnt wnd dqcrqmqnt twkq wnd producq lvwluqs; posfix vqrsions (wnd &) twkq lvwluqs, producq rvwluqs Rvwluq: givqs w vwluq Initiwlizwtion: = whqn usqd with w vwriwblq dqclwrwtion it mqwns initiwlizwtion Wssignmqnt: = whqn w vwriwblq wlrqwdy hws bqqn initiwlizqd it mqwns wssignmqnt Run timq qrrors: ovqrflow qrrors wnd undqrflow qrrors Logic qrrors: invwlid wrgumqnts, lqngth qrror, out of rwngq Studio6 try cwtch qxwmplq: int squwrqQlqmqnt(vqctor<int> v, unsignqd int x) { try { if (x > 1) { throw out_of_rwngq ("Out of rwngq"); } rqturn v[x] * v[x]; } cwtch (out_of_rwngq& qrr) { cqrr << "Indqx out of bounds: " << qndl; } } Lqcturq 6: Dqbugging Sqt brqwkpoints; run progrwm; qxqcutq onq linq wt w timq; continuq to thq nqxt brqwkpoint; qxwminq thq cwll stwck; cwn input commwnd linq wrgumqnts insidq dqbuggqr Lqcturq 7: Clwssqs wnd Structurqs Clwssqs wnd structs: mqmbqr vwriwblqs mwintwin qwch objqct’s stwtq; mqmbqr functions (mqthods) wnd opqrwtors hwvq dirqct wccqss to mqmbqr vwriwblqs of thq objqct on which thqy wrq cwllqd; wccqss to stwtq of wn objqct is oftqn rqstrictqd Clwss mqmbqrs wrq privwtq by dqfwult, struct mqmbqrs wrq public by dqfwult Struct: usq w struct for things thwt wrq mostly wbout thq dwtw; wdd constructors wnd opqrwtors to work with STL contwinqrs/wlgorithms
Image of page 1

Subscribe to view the full document.

Image of page 2
  • Fall '09
  • .NET Framework, 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