Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE 2100: Computing Foundations 1 Intro to Advanced C++ Ian Parberry Summer 2013.

Similar presentations


Presentation on theme: "CSCE 2100: Computing Foundations 1 Intro to Advanced C++ Ian Parberry Summer 2013."— Presentation transcript:

1 CSCE 2100: Computing Foundations 1 Intro to Advanced C++ Ian Parberry Summer 2013

2 Some Advanced C++ Topics Templates – Example: Templated stack Operator overloading – Example: Complex numbers Copy constructors – Example: Multidimensional vectors More examples – CImageFileNameList – Arbitrary precision integers 2

3 TEMPLATES 3

4 What We Can Do Already: A Stack of int s class StackClass{ private: int *value; //data in stack int count; //number of elements int size; //maximum number of elements allowed public: StackClass(int s); //constructor StackClass(); //destructor void reset(); //clear the stack void push(int v); //push v onto stack int pop(); //delete and return top }; //StackClass 4

5 Stack of int s StackClass::StackClass(int s){ value = new int[s]; size = s; count = 0; } //constructor StackClass::~StackClass(){ delete [] value; } //destructor void StackClass::reset(){ count = 0; } //reset 5

6 Stack of int s void StackClass::push(int v){ if(count < size) value[count++] = v; } //push int StackClass::pop(){ if(count > 0) return(value[--count]); else return 0; } //pop 6

7 Multiple Types of Stack But what if I also want a stack of float s, or a stack of strings ? Do I really want to make three different stack classes? Tedious to build, difficult to maintain. All we want to do is change the red int s. Answer: Templates. 7

8 Stack of s template class StackClass{ private: stackelement *value; //data in stack int count; //number of elements int size; //maximum number of elements allowed public: StackClass(int s); //constructor StackClass(); //destructor void reset(); //clear the stack void push(stackelement v); //push v onto stack stackelement pop(); //delete & return top }; //StackClass 8

9 Stack of s template StackClass ::StackClass(int s){ value = new stackelement[s]; size = s; count = 0; } //constructor template StackClass ::StackClass::~StackClass(){ delete [] value; } //destructor template void StackClass ::reset(){ count = 0; } //reset 9

10 Stack of s template void StackClass ::push(stackelement v){ if(count0) return(value[--count]); else return 0; } //pop 10

11 Declaration of Templated Stack const int STACKSIZE = 42; StackClass stack0(STACKSIZE); StackClass stack1(STACKSIZE); StackClass stack2(STACKSIZE); StackClass stack3(STACKSIZE); class longint{ //my own long integer class … }; StackClass stack4(STACKSIZE); 11

12 OPERATOR OVERLOADING 12

13 Operator Overloading C++ gives you the power to define operators such as * and + on your own classes. This is called operator overloading. 13 class complex{ //complex number private: double imaginary, real; public: complex(double r=0.0, double i=0.0); friend complex operator+(complex, complex); friend complex& operator+=(complex&, complex); friend ostream& operator<<(ostream&,complex x); }; //complex

14 Complex Numbers complex::complex(double r, double i){ imaginary = i; real = r; } //constructor complex operator+(complex first, complex second){ return complex(first.real + second.real, first.imaginary + second.imaginary); } //overloaded + 14

15 Complex Numbers complex& operator+=(complex& x, complex y){ x.imaginary += y.imaginary; x.real += y.real; return x; } //overloaded += ostream& operator<<(ostream& output_stream, complex x){ output_stream << "(" << x.real << "," << x.imaginary << ")"; return output_stream; } //overloaded output 15

16 Complex Numbers int main(){ complex a(1,2), b(3,4), c; c = a + b; cout << c; //outputs (4,6) c += a; cout << c; //outputs (5,8) return 0; } //main 16

17 COPY CONSTRUCTORS 17

18 A Vector Class const int VECSIZE = 4; //vector dimension class vector{ private: int *data; public: vector(); //constructor ~vector(); //destructor vector(vector&); //copy constructor friend ostream& operator<<(ostream&, vector); friend istream& operator>>(istream&, vector&); vector operator=(const vector&); vector operator+=(vector); friend vector operator+(vector, vector); }; //vector 18 New Not just friends any more.

19 Vector Constructor and Destructor vector::vector(){ //constructor data = new int[VECSIZE]; for(int i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3190114/11/slides/slide_18.jpg", "name": "Vector Constructor and Destructor vector::vector(){ //constructor data = new int[VECSIZE]; for(int i=0; i

20 Remember This? 20

21 Remember This? 21

22 Remember This? 22

23 Copy Constructor for Vectors vector::vector(vector& v){ data = new int[VECSIZE]; for(int i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3190114/11/slides/slide_22.jpg", "name": "Copy Constructor for Vectors vector::vector(vector& v){ data = new int[VECSIZE]; for(int i=0; i

24 Overloaded Assignment for Vectors 24 vector vector::operator=(const vector& v){ if(this != &v) for(int i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3190114/11/slides/slide_23.jpg", "name": "Overloaded Assignment for Vectors 24 vector vector::operator=(const vector& v){ if(this != &v) for(int i=0; i

25 Overloaded Addition for Vectors vector operator+(vector x, vector y){ //addition vector result=x; result += y; return result; } // operator+ vector vector::operator+=(vector v){ //overloaded += for(int i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3190114/11/slides/slide_24.jpg", "name": "Overloaded Addition for Vectors vector operator+(vector x, vector y){ //addition vector result=x; result += y; return result; } // operator+ vector vector::operator+=(vector v){ //overloaded += for(int i=0; i

26 Overloaded I/O for Vectors ostream& operator<<(ostream& output_stream, vector v){ output_stream<<'('; for(int i=0; i>(istream& input_stream, vector &v){ for(int i=0; i>v.data[i]; return input_stream; } //overloaded input 26

27 How to Use Our Vector Class int main(){ vector a, b, c; cout "; cin >> a; //overloaded input cout "; cin >> b; //overloaded input c = a + b; //overloaded operator+ cout << "a+b= " << c << endl; //overloaded output return 0; } //main 27

28 MORE EXAMPLES 28

29 CImageFileNameList class CImageFileNameList{ private: char** m_lplpImageFileName; int m_nImageFileCount; public: CImageFileNameList(void); ~CImageFileNameList(void); void GetImageFileNames(); char* operator[](const int); }; //CImageFileNameList 29

30 CImageFileNameList CImageFileNameList::CImageFileNameList(void){ m_lplpImageFileName = NULL; m_nImageFileCount = 0; } //constructor CImageFileNameList::~CImageFileNameList(void){ for(int i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3190114/11/slides/slide_29.jpg", "name": "CImageFileNameList CImageFileNameList::CImageFileNameList(void){ m_lplpImageFileName = NULL; m_nImageFileCount = 0; } //constructor CImageFileNameList::~CImageFileNameList(void){ for(int i=0; i

31 CImageFileNameList //safe index into name list char* CImageFileNameList::operator[](const int ix){ if(ix >= 0 && ix < m_nImageFileCount) return m_lplpImageFileName[ix]; else return "NotAValidFileName.bmp"; } //operator[] 31

32 Long Integers class longint{ //long integer class private: unsigned int* data; unsigned int size; void loadstring(const char* string); void reallocate(int s); void grow(int s); public: longint(); //constructor longint(unsigned int); //constructor longint(char*); //constructor longint(const longint&); //copy constructor ~longint(); //destructor 32 Note multiple constructors

33 Long Integers friend ostream& operator<<(ostream&, longint); friend istream& operator>>(istream&, longint&); longint& operator=(const longint&); longint& operator=(const int); longint& operator=(const char*); longint& operator+=(const longint&); friend longint operator+(longint, longint); }; //longint 33 Note multiple assignment ops

34 Long Integers //overloaded assignment operators longint& longint::operator=(const longint& l){ if(this != &l){ //protect against self assignment reallocate(l.size); //grab enough space for(int i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3190114/11/slides/slide_33.jpg", "name": "Long Integers //overloaded assignment operators longint& longint::operator=(const longint& l){ if(this != &l){ //protect against self assignment reallocate(l.size); //grab enough space for(int i=0; i

35 Long Integers longint& longint::operator=(const char* string){ int digitcount = strlen(string); int s = digitcount/HalfBytesInWord + (digitcount%HalfBytesInWord>0?1:0); reallocate(s); loadstring(string); return *this; } 35

36 Using the Long Integer Class 36

37 TexCalc, the Texas Sized Calculator Just for fun, I decided to code a calculator that can handle not just long integers, but loooooo- ooooooong integers. 37

38 TexCalc, the Texas Sized Calculator 38

39 39

40 They Get Approximately the Same Answer 40

41 41

42 42

43 43

44 44

45 12758857994094198151763893403480541966683204398832742671049843097263646953668006259327894302669719622580966377315480838861344578339557928252631510206214991990777857971500127409510060359960695166866539168326861490640814475620678449126990 42004605583859910583296526857941105757626504018649128339148781194823339323446481117083293322698067026547918281513676316849030469366358516642559454823133638035539339277605039058137318445884778383248100692858253951525535431177679794667731 67460646362487188723151868446440416397097182255841452460789290891711674008438057399591311416507362273444867275663090995447004552700636268270445772692791404283163247378520596232631427080019735005719207233486016681321109064275913965759112 35130536330130190508748067821423810661226871543376286781499500535176123612972356263600232849857227651058812162693967331999782794018743402903938329230778402584052851862980867050991721009484096677491014261812444164930797643636602882721683 46175441618616005764029300263591697625406763232697474120529751695729845039729330986795021901008610499702709097286855283354040157412549946699213963009684426437638063843671173964064453506427617835442591534065707280238153034608846152432785 63796240367182710304619665204299319343286321421204690046312336414999095812152998932549451093712373015238539456618742666392503201924043257555633027212074936117499100987843334010894884558373187865448574332448856420590734295446182836017479 29260887325236070963314815877172762439526533256707668808603763256053949346317025836898892982896322469562071882991800263582807915371165032579693075968350683837425027388851105182880235149710149529535298656386707265271218577177738601396321 92808259958953493423527284720471908058039732584338769964819223011274606781443793493806295410084755965525439086191006966680177530836503541792126399947271806778069228704182873969940137774678399889522367823868576645180941564558843594941606 52314351239205369498024597273522640446310936206437805818063007526628254687628028899536294827259491864072676110335669035433212311234212254571695784554627787528078720935208982128410586004625890069591776208684363319939609807313448089462715 94083675074142106527961233368000128351218988674549553759418498805331116696675332170365395446858627553532111479424986661634038578010493408987973304809794265864120897015625937494902942765792285459756229663972771070455385789324521154089162 67681453558043967127592741958652387982752857712992457251201099705937548295650520733236810082144492570986848058212578409746285245558613896567620752493771105755934176551914234311892713667283474402716479922415958362475766742616388549432880 92352950972251334168969766160680646921798879282878430276988931435119603934969900053298743173612405642674025734679535804703383760809141042709115659877635077429122604752230088525971291955502876076520098087470544232134222601779246488759792 17640773776916053093325804837637662468564800649515759148432013238200889633673681759362867322940677431249612453275272477818244386381876118110537750256682621760294846278709285650202054505186889309676358509511322793207175411230330332176860 59400127385870296857911639330087028468583913588797975224982043375639049209672787228013178897226042944975375567897222548172127100560479411246606471250470353411140011724318254899998025924647837316037002389173809581539143187223553639155626 98136243307964176533409162082123084788050425586996228694437066284951962070442314594679815024583756107322663572530147293887550817221410972462550731756707080413663652318513617769501656238392559518980676884452388973400824724371384802760402 03856826600551746220817162825382041233749671240879916198082122090587237714576584767449161291204421532464075967770553294331751455336094978822025056012489343175338230086669748420770806340378983390599876333638671609120421861889086894442066 98359084944721103131532441479849119427426297305968254064898116538064026592939424627446551311318129721671355625633306509290146158899233351448044420564898837053074774241602546975932912398477513830822011730904563518812762155683893500484347 18380157261053041999306760998847943301716111514850075009546022388565296160964580011958733729391753105750013379004230373801928392244494463401697176707286068117949891282301949127209324903371338067349298142125701153783144017001015587257609 76252202855321349169844964713900459397444121946523307796557282807069655150328659610046751007991603184572775358534305456398448883981949478217512669547674593490688480024388456941359438816867408885476446345311613600514921686057127363874767 28687164663015101644534534512097826151150130544924145497294562570285055676215864470126564072011885686076723618348574942888777441403423638197979389038571998001686921640628579912908795530607419979967977632636736810637187603580265637771157 88998718893167912180396234328238297627818059863171705612652402467391599151644261676548629032416876057994537770601488177256141214620610089941756842319185716764894316204084992781670617237835351410411823804446353051301773883026584729404067 40171272374374498917851051990580475877115894114209627500831276817680570786708050256293191789702280891577516465157769090798419041119558960555905208040446898233449291300652991171077041736065242263819167990706772056284230856676677055057344 07277329272136948611244172316421499890431696839045830010375498847237717756014662324863794633756698770086226366252217131090390171001698565924598611292869807850745167323520199614049453696610113882772575158176706782826456479188852647195070 76965221630063960378686949370810620626531080491751962669278056489779436157566367380754341257977981866960333549112576687124242310385572207124549840151156546942635375536019947258150803427869701554982176953312397901897147131390678214325018 26344057542579529195474176468755080602190373728354414062829854833225991158420976385720855846493421320139651286951942473212697176147679179670963096574316973381645139610495707909932567518383492013499901432350997553472976308467478688115510 84465676756787319134600969294725611512881722220381163321131348371389583484263707529779469777538338879489955134798643965920898468221165349637080419074019753767684497116305040153375368936074004080786072447875453978755726301817095569631504 62093597518899463904605486210372559265029035940240661844007404704161399773417259800284911806551649407054148665685296460080280555148823637307116578619547061539231238889589495958884313107805883667509361698203186728782760166460261745024194 35880332482010148343176304330279515085558418993608155662425502117469153288390707804327892490278889061517570304318320182846546195621173975636678253963952252976394286438909988089452304237098629846237958193921463980239965528338173086460704 64332608480885415039991468671435142470709237232500629705952432780271472325046016960643475747756291625284881238963850469126244739978789937516768209981508781422507759668328452735827588142734300273725376435238667532489930299149561851705893 59416923775704744851052161313606495110445317503729043916971805965975222634072929123206994223817611941703087899017390579496519412518626888236124207793831956787978955022774583410161607647701589550972697471311791822596392206098297596828453 00894845854689779702781315589636911563086468817423579242560832719954411098224751467278836385583085794029693150541428135965538318220393789904018092997037259177755279732356632317078956866294736597711098139261789044521803933079183389890090 13615487330810903098306538025364739320816017733066961509886288558989076509471829555786069822941502748701351451376049784036255279254639460489687884920552455246057158802704201124674260964360925536056912100072064599386856601630481476368426 18374383326988022568105664053909931576080818407081690115339957947727929237790188258959440667102221903375576267445391639505962389786727815581609979378234524938527098213356435780335321607187236454114615591804006624156158040713959053546221 87410003222283811817015786046605307144904545380954737684453419323891163072736224006747802265023673083320182376119820980708850345229314929622809652705297558042492878619054178064290199170087715456567053094104528015433943209346473283729012 14752520951460877341593196578671327175477041689948696136781749710013053275154044660632522628089306504094218350071195286108570658713999549372771865721933302234255248057465741686467112328363437134069539641415782590309464623636956814456674 00305676147362614044010350987505530267749798769026870661876075584859629107487809258738395445627788356835960331099182558966520593135187993081783249116714407535277142702527765151602994245862811885011429638884349742150601592362254124887713 81987973965527893801548710417598602782051667637059366185369047083630337990326528726664601872397636745146882235933838781016476553244447645321770554523665095209455467575473512819736600691204833452490948163495433689926167409117691498192995 28905193908338726382654706787638711251893119756422060500317331232844998449024592925628035961575607857795646109606784876305007545753462607697121712479191710665691650630402104267973795844385417520054343344973750542767562402432422023387122 82619589746099831456993909661990937661243733202227379575136633444678578564984417452174079742074738458996365737838353977085621569653200897802329928689278670981973202515499459815668889961692647881314088412725013949978808276325677789587445 39118992642086270980161868510255545899188120608413858657354674344953012747941687859030377346376777825960303221602969998593319395171537186477450640331213465983142429644937085094022891598038785432294581220728145000450175276857468513938758 52173525171862429341468536435483823052975748703123264329170875225878775170528700953725128334441443911639397522689179222729223845574217923992484832433017515913123661362661823725582800487181126362210796548865684394840196440825978767630228 53293144852222645631667641436324504324627395989247814297217819723289056067073622750183249440528382627285103550423695682490389792015015616789404980375308541304535327710333477414645202438381373609617584776592561465373286999336861481873655 50434150614573430124287414892685608584910654079848113370345727609527488803682438168751370456384870654361956263916148021949215083448584401917405587020575345256859933060141793495895301602355780733081221815849973975583497941866093265654188 46317167178752342513640799680255725231942182084216984413044051617066361548510089499443460999091991795183575860654670411107867872957166149535648767921629265081045023330780532853313936682286551201161349568682113952206620466250339390593966 31674052365237250752897583922657039738156959723873815986726473380143306389077334443997606563071244362938971176139681529784945415586567584011938233160257213684397064217951034062775255734639424655868592488178729659219077224388376405485557 90967845970502385686438191430294303175191404557420142316057061128101905536971708483308984433296227120506851490007855157879656889084103940867504871946234792924365992487096285541263736094590957500421381947329819706460888062479523458603579 15852431314453598194676409105219811579988394926525319346186140635396725596004826668542810216913742754669490405000268571941196465328595521005442734930924674225697329792885159230038405653780187251222870353399835252324568803317722925303038 23324116121755841247015441168651825949103031405403429474931590758708556098596660516827244001651324215964124813469819344162141833477242611795924909440690003777435508086906963385595034340347736508269522766920465954759705328388331207324335 22159493757571918343659442168983702683520092116242958450013879989663267493017688084771000313791569347048996061606734846194981456704401030151964631197687134075354520615215654033210720832064570169261186256775125877059740016601894493801143 44182675268110432838385498052420144700629711646596581576582618408582431084001259174315350836428831111948426606388439832841675601612864695141746484152719160478563633895492713183175787855814405045628013762387204515917417572804137589429741 39231637179912818186970160604183183420037205282232297887637305809271065204196525854809296626623560749866969106692584190598127004334505317567102126512530607700272531849308626857231899903810495410108290954780053945624371013508035087584873 66034137181544095119580550310594883885307794511320654256855211540635023183029582616829790261039567824627051206354380293478590344060798970365116296234801927950409452932173307881187238080002128688167513375543009109722331859017996215293597 00182027703014503054063143975748214795743989832891242731651219987182274616948423483014633445324570807603876473310555926253909827941063541655190059417481610050109561527299708062068758922420648085570562569096078357675381550173352588842462 10023665929696861045882572087600454355040485501880633684157768544685072588063380899709005560329619342886457564302752969851590044921382817827107680712486426318693190614840429745571421627182380225163145830092034390814362573673970185236742 32339847294084957790064796992522918297942417953127459847390703307186138318905371515674970112120255560948506607451645800216443342028549614743553350297621154345874465871954831961874576812048179851887091903157568387444700982549653566803880 29625697448251642512377523691345729942878891683189259790500459241602955472692868645194091644968377804090056724182393874253814526698622713957826222318130255151917588678276738366531160358161873244409482554725046472486383817309941244504080 51968506325934523569799477098083531118791176598843137713744208898827708993411445898360458255194712959875520764788396376154329830882483538300287739644367612179465722963982576105277183629401656344139305970676171469091145909346486455907565 12218994473408305136243138066056518596297458089757204024739680387388571872890439973878629686130108949155307861499665665597764116756520264195783725092550323687007565934435413310286405585149625964026178762084087935717020031829620280350797 80211812953417884556959277479813906663873036252023368108724559922233255456530017810787992749254106350552489471045833883969598470371117693469625945997848069037947482648977258043359663704903294665785792269936514962753009485640631673302100 42721863550025929329160739103446023930929258377567270269902507414503071790133375954523815924629463465762907371377188185711937477221759041568436354527803548544256235086231993372653656066422536886002399030200829152444905958246979665515976 32835235648279906381165645825876959604617157119695790893849194477214694332599902572982703392065163901955512631943913934623634543025022841504817601035753212268519637069492319599445076733460722830771129415318313601635685927077457980202113 04892816321550611528917050709952113155562805248263403674556878563809992709627289586464167003224929307238955060889415607729741281463786549766145644788820571348184267444543050024513521464948445766881922503705957350921309406724594393309843 92882189548655995662119196569683818120033264905475457594664182629350308166285644259209676322893015768163327272062737191286781650132359927376446393372127582222112429223156735629773074047718990156594983086737900292374783702065941537212869 78429283943503730735641594241059010039733139468170340355772153330156565113414667178644075108230232009516016336127597241120512177969865954956977298502029955613049892860630875330154205381116562187592484704815884166610026853695688869201444 67453809525747437640979275215419421392485458850988155475452123873216748490175512115659001185984705726707841033148113845170273410729846639092260738374778811349211599705372401168479557851911126656048600211761962313842644037879419903138931 20753341960081092839106154763824236321201680051972180357855129846680098482829132525951885923525196867743297039784716928284082593855167522280077750917463039370701746598966747502056194504354558942716480450267092523388350376047811251050269 35350232261181011370942820351595882881974369448186364940222443950701533710278824238695491940541767890867199403334907763170528626049510053361847193634941101478802454210418062268218898174101644458343559325440196536615206184380673332060687 11148797049977505474329879511112681006788831288305550217818033563537844770727044029691879574678872570665782486035527240272278640697040172676966268451215852324582101194742061525557812564453387714406069446568557296833891922333917973171781 71239823144476501756978613820462642868647551208100886916135666383590737681362062309472642353493411533863768037019656636389856544091642037841710122253350748102200981396587030850943460557252330568066482868142563623420780758255950473360050 38433386690761679218573176883055094891559130772168133115385809530010825992376516991210463267646313814179380878303205001853594807149885053282551007346300642377517727210413777557557583837286067261774456581557537495468278283676939836264641 20663268900779889011610977485795045454249188894632682998277800095777729909490506987330274655022172974270055617103171381531308634336085677697835661682929287159838789826930383315674460217354705705234187446810381730464144769127502716306117 56889635249426487264692842290904781194745941430783178091189646314066917604083989350262307211301303580456635174482391433842999482835054033716433070458881691777662129391528369949141518401106129194567734014377475810174400798426532976022413 33554718307304320644188606068811659599394614896960483041659898539110167378359429657612587659566946452102617906350528508440493674236947864572423192238761053202152335901832093809793821577933097023967391686571143687459468418390462069616454 29805778334063190389942334020411178682896069243807140681786973729641180611085156753661027633511055611147902653691005486364739144770418115605566603040818894100496165095761549293775405038363974675765612428223961167095350394284144798049066 93039094378435574833475112066640379804067580431988390923898935080813623432550839486540440038544955666643542289736820879912831449699814809602401584604650020102568425091179644532240358647662749454724379745738213068046994645565439560880741 06882794116688334423593341889830196714631357637174603825582933934193952862764531242198236877233829590072187687088875718037245670852329424037814187739195871825645801886639462347256421652700889141075520172942478207429608948681351802330751 78437704862253792421058681137337857704094916539627784506331191336270494117004459646827163273707499551661503016540277401244532340339070015314519372532924425555358290125862503440779017980396625693802402822409153201651439676459682161780197 70941894693959803079578370709637040466144586613099043263284213705743136553063873524090263778725423379174653665927176208138424195670162461689989497707370931876456892360398252817526938849005394548611431153252028109310352881429921651774534 42422883461243035086638357487982888073504507757551400963423781632025338748737638079789631195375506799317771413889731358238129884733017002017453858078636495152966927956242485317319080346206995324868767996699505494245709073901815071533354 71587933472446616419340922483929351763543609651165500079565951112158564861195932666467768922371943385930573088509605045609698617292035168782151463948247477864458624213351011609132904061103927386683994594029692839452814741913098822705817 92002268574415677402981607005261319968633806750195105964656703785962179808639177394105825889115946970263483034832945745752325440498091707357197090024818110360318566929607098084292088041119877791173525871680025005284391914625081845452621 35221140834357248781538354592031253712459223791042035745921497968781587134192465023182560910078702085524432259345373967985007006036190802981588353512464418421942012167315707285479611135877265836509293236335870691111099043466599391898561 86633203817348222708462294883469455343624547846732869247932344015216320688267793910071151481399883449453759825144220806257772738183442688813932035064058294919506294602275218499276543341350642484228940953995208659689884242762028844713291 21754023394671488073130410764573027673229208205550924481710345915547599869440204524788479168498285651395409218038017065295886171863378179247626805702380529275820900837446827556630707293905055894871785972718449292170204180898937528489126 22849831097150992032732006204512743070369261730499127385176896476598195780618352772765619662129107041668641627872940583269833911486121461762966838887157458083025327419312888626828722117738902335956085314553731985755137782589015138151068 89159613523025843451155988334893642554129230492988196839904166354811080340327555712138220793006730910426051924446729399954873625137237986784388240679203683646697036933493576957975653262844332446974125320378849584931681066747900951780077 10034445970264627420491159519867598969779373090989675497312909414511336761607938980650608243773014510232213095052618385878318719147172096814357239526756863267301339054857062484582947566098969243224820643977360947341209022092686275602336 29744683003968466474337156159168176735456971278372418111989236471409575236087201779487404154851891522298816162930163161759649088601452195447383328529797365957888806161967429248660733863683037175010567453361210743159115130197800830043605 13453608072733708165243657459283518791942503607678615337770685032195012615535667863226570418368483713612269226578891145635941648037579957791692984722753611080790907712229776359266336063289604586695427664400730509526007595810168713320970 75829320719669204145918656225922153915724445415565626346153016849721248523781414626263150296547875226746829119152896127467874899130155863386287849452985720142040769012025573633967762398974792407026826356928442108993342920725805991877749 04634035331200042127193921851362102469514792927722990386951885330813216188302346391703057002695229324360208369287844199933677803432810001784264556266704252725285094962373125844234584903196883673114859705694476680251044763740138378527325 18335677767793355956082627747893042117165911044023182622470947848376480916118320636046950350909699092280407053420254593372378116327111844433022139883092542287770259946182556214004216576226039482041432600344217297861608082718335173850291 95834575372218735074073200156872076349749366078076413810747967921858039629812756460205137762295660242955625030422582965867399414806855971160078805017176453121272059177541951398000368112451537940652231885799233275219625332225203013643499 29804857100862058301155673208371011564143440694338175418942371827441020183191246861295086748854579926471887166065337758021557673796020459862109474668432697162042668791846094903662616342450953008121670718303285161120530611965522134027992 43246223900949170378051255937366824943122060031856719390274529314108289980909943805837441073913943352584517054724849147001514242412999081259145342201617095501379555549791409563350780270782690381946653705593649719540671156120218781623357 12557103331651917363527866499951951695481401043779447632479522515975970584914589212497506436362709613549311812244097441156234492456074572114907693816642610946112734153238143531424434306750112552707723105778194194636886481821745579694278 18709185673377099599287046405676001829500775486603908360869616560721455677543677976649182212290551033156720100228155518906391864691385941545219342650653351537284981606104635926834756802281892146625337354904001493025158928314355088280232 31436241661422620307074772831906366008284601281815142513716192523910657717224855559122990365764385537855435576105237560814400427693543529418696040949477587654940202184883880519288559351637588358665010382560510610617417354499342971121443 83509682566100555045480977176804388817188317339409868377399011156619072259174988739799647963764768233208720417288363305850216912824500427547120739005698961602574186615510254172951316735316665108141937535752689827671344316290582683550047 62249085301018133393304608885257642601873068975654378712483799473683350278245522285956625946847381865548248912933586779993225405489638257616311181852091538795133341770622892005426504498735590774969694666400287038791916619103448758339816 43922741918023653205495738036842080708187186460561110993757125864051101555871042160247243512760351078068739408349282303879571340322544299545666819604081861563195090210359965797887774344224361814197785496318708071204666550643048777079121 40393212038533447840342667562532895070680309348306174545696921798792324659232816265675154312410123900410289527023660540387006909186598941357093788830921829397038233121581689989354751279165688331720860315143469136160611173905214283274706 70366374300394266098380912177281785798965314659621610845507676770856153094783481186374780477552959316510391198894935087957473174069796705872598322016544734959404317243392407621651981043506251020751933262770408401714716073151169605507903 98856043422973078377476853300181186006962138937260231310200339827783120591228165231643267242958991717931821770408451400213315077346179854657451669813273886620166175335244162479909804325365498962101407148649912979281505319070633151151057 52590313664950468808897241974300014047962582579381906944762632002871048520329937719700227436254591150534922204153700036722664639973111591604937655146998793824764878507565532705620704856578393228036125644369942219099552348465532766964574 99005438161654323444339971376476451750667779723313503655592268861014497823254163688155924415465506765972289598427401077787803099394544360535358388499470221385404711170148790230647187283318835116487169468033291602138901453251340870464215 84109724182531114847451462953524494293656213219435764990190830880622768671023487594864245374873911042687144522999491511042003077695967606169114533860189654449616153731121908286313924822349768127366130956052073399799835532841888434857658 95923975962542461003911824162410237473261192027719673194482879028948335699795395127007665025059345103605664642457131217434342340373562089928395850261594193989211327815633358983405272959152360096236954561937516236552835280953323535809591 24560354473639105511217595161679248389972797881872156777297382921005730853895384153178424706336989213261124793478550708027330494162307209483478911404551206487824645412537910887828438160261974712538965908411223805143446133487876418439792 21357700980550895909124556685250791144766812666458000883861534573057357702819511001264398713814196420694356692785479304183907407126372154585874654929359813404006673675221793246681752529031178811899714770479684691012180528804825838402225 05174940667550153788927329891217095357090494775885188781043999002641081162005507303548903232857609956666466349534920048319433085817609754880090025691728639574973948528106538182429789094654243730105406793620853559770235799256220477233646 25341771135467597305530194686544316037838038591440266636670622802186595131502308720263949809705295137098964641443803835752539080004951242547092561339747291309901302482506158933719456335813002961137644481018747639551445346675685865881583 89432595406009546476984729600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

46 Programming with Overloaded Operators 46 How many overloaded operators are used here?

47 Programming with Overloaded Operators case SUBTRACT_OP: g_lngResult = g_lngOperand - g_lngResult; break; case DIVIDE_OP: g_lngResult = g_lngOperand / g_lngResult; break; case MOD_OP: g_lngResult = g_lngOperand % g_lngResult; break; case EXP_OP: g_lngResult = g_lngOperand ^ g_lngResult; break; 47 How many overloaded operators are used here?

48 Programming with Overloaded Operators 48 How many overloaded operators are used here?


Download ppt "CSCE 2100: Computing Foundations 1 Intro to Advanced C++ Ian Parberry Summer 2013."

Similar presentations


Ads by Google