Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Size: px
Start display at page:

Download "Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved."

Transcription

1

2 Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

3 Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-3

4 10.1 Structures Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

5 What Is a Class? A class is a data type whose variables are objects Some pre-defied data types you have used are it char A pre-defied class you have used is ifstream You ca defie your ow classes as well Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-5

6 Class Defiitios A class defiitio icludes A descriptio of the kids of values the variable ca hold A descriptio of the member fuctios We will start by defiig structures as a first step toward defiig classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-6

7 Structures A structure ca be viewed as a object Cotais o member fuctios (The structures used here have o member fuctios) Cotais multiple values of possibly differet types The multiple values are logically related as a sigle item Example: A bak Certificate of Deposit (CD) has the followig values: a balace a iterest rate a term (moths to maturity) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-7

8 The CD Defiitio The Certificate of Deposit structure ca be defied as struct CDAccout { double balace; double iterest_rate; it term; //moths to maturity }; Keyword struct begis a structure defiitio Remember this semicolo! CDAccout is the structure tag or the structure s type Member ames are idetifiers declared i the braces Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-8

9 Usig the Structure Structure defiitio is geerally placed outside ay fuctio defiitio This makes the structure type available to all code that follows the structure defiitio To declare two variables of type CDAccout: CDAccout my_accout, your_accout; My_accout ad your_accout cotai distict member variables balace, iterest_rate, ad term Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-9

10 The Structure Value The Structure Value Cosists of the values of the member variables The value of a object of type CDAccout Cosists of the values of the member variables balace iterest_rate term Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-10

11 Specifyig Member Variables Member variables are specific to the structure variable i which they are declared Sytax to specify a member variable: Structure_Variable_Name. Member_Variable_Name Give the declaratio: CDAccout my_accout, your_accout; Use the dot operator to specify a member variable my_accout.balace my_accout.iterest_rate my_accout.term Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-11

12 Usig Member Variables Member variables ca be used just as ay other variable of the same type my_accout.balace = 1000; your_accout.balace = 2500; Display 10.1 (1) Display 10.1 (2) Notice that my_accout.balace ad your_accout.balace are differet variables! my_accout.balace = my_accout.balace + iterest; Display 10.2 Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-12

13 Duplicate Names Member variable ames duplicated betwee structure types are ot a problem. struct FertilizerStock { double quatity; double itroge_cotet; }; struct CropYield { it quatity; double size; }; FertilizerStock super_grow; CropYield apples; super_grow.quatity ad apples.quatity are differet variables stored i differet locatios Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-13

14 Structures as Argumets Structures ca be argumets i fuctio calls The formal parameter ca be call-by-value The formal parameter ca be call-by-referece Example: void get_data(cdaccout& the_accout); Uses the structure type CDAccout we saw earlier as the type for a call-by-referece parameter Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-14

15 Structures as Retur Types Structures ca be the type of a value retured by a fuctio Example: CDAccout shrik_wrap(double the_balace, double the_rate, it the_term) { CDAccout temp; temp.balace = the_balace; temp.iterest_rate = the_rate; temp.term = the_term; retur temp; } Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-15

16 Usig Fuctio shrik_wrap shrik_wrap builds a complete structure value i temp, which is retured by the fuctio We ca use shrik_wrap to give a variable of type CDAccout a value i this way: CDAccout ew_accout; ew_accout = shrik_wrap( , 5.1, 11); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-16

17 Assigmet ad Structures The assigmet operator ca be used to assig values to structure types Usig the CDAccout structure agai: CDAccout my_accout, your_accout; my_accout.balace = ; my_accout.iterest_rate = 5.1; my_accout.term = 12; your_accout = my_accout; Assigs all member variables i your_accout the correspodig values i my_accout Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-17

18 Hierarchical Structures Structures ca cotai member variables that are also structures struct Date { it moth; it day; it year; }; struct PersoIfo { double height; it weight; Date birthday; }; struct PersoIfo cotais a Date structure Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-18

19 Usig PersoIfo A variable of type PersoIfo is declared by PersoIfo perso1; To display the birth year of perso1, first access the birthday member of perso1 cout << perso1.birthday But we wat the year, so we ow specify the year member of the birthday member cout << perso1.birthday.year; Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-19

20 Iitializig Classes A structure ca be iitialized whe declared Example: struct Date { it moth; it day; it year; }; Ca be iitialized i this way Date due_date = {12, 31, 2004}; Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-20

21 Sectio 10.1 Coclusio Ca you Write a defiitio for a structure type for records cosistig of a perso s wage rate, accrued vacatio (i whole days), ad status (hourly or salaried). Represet the status as oe of the two character values H ad S. Call the type EmployeeRecord. Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-21

22 10.2 Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

23 Classes A class is a data type whose variables are objects The defiitio of a class icludes Descriptio of the kids of values of the member variables Descriptio of the member fuctios A class descriptio is somewhat like a structure defiitio plus the member variables Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-23

24 A Class Example To create a ew type amed DayOfYear as a class defiitio Decide o the values to represet This example s values are dates such as July 4 usig a iteger for the umber of the moth Member variable moth is a it (Ja = 1, Feb = 2, etc.) Member variable day is a it Decide o the member fuctios eeded We use just oe member fuctio amed output Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-24

25 Class DayOfYear Defiitio class DayOfYear { public: void output( ); it moth; it day; }; Member Fuctio Declaratio Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-25

26 Defiig a Member Fuctio Member fuctios are declared i the class declaratio Member fuctio defiitios idetify the class i which the fuctio is a member void DayOfYear::output() { cout << moth = << moth <<, day = << day << edl; } Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-26

27 Member Fuctio Defiitio Member fuctio defiitio sytax: Retured_Type Class_Name::Fuctio_Name(Parameter_List) { Fuctio Body Statemets } Example: void DayOfYear::output( ) { cout << moth = << moth <<, day = << day << edl; } Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-27

28 The :: Operator :: is the scope resolutio operator Tells the class a member fuctio is a member of void DayOfYear::output( ) idicates that fuctio output is a member of the DayOfYear class The class ame that precedes :: is a type qualifier Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-28

29 :: ad. :: used with classes to idetify a member void DayOfYear::output( ) { // fuctio body }. used with variables to idetify a member DayOfYear birthday; birthday.output( ); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-29

30 Callig Member Fuctios Callig the DayOfYear member fuctio output is doe i this way: DayOfYear today, birthday; today.output( ); birthday.output( ); Note that today ad birthday have their ow versios of the moth ad day variables for use by the output fuctio Display 10.3 (1) Display 10.3 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-30

31 Ecapsulatio Ecapsulatio is Combiig a umber of items, such as variables ad fuctios, ito a sigle package such as a object of a class Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-31

32 Problems With DayOfYear Chagig how the moth is stored i the class DayOfYear requires chages to the program If we decide to store the moth as three characters (JAN, FEB, etc.) istead of a it ci >> today.moth will o loger work because we ow have three character variables to read if(today.moth == birthday.moth) will o loger work to compare moths The member fuctio output o loger works Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-32

33 Ideal Class Defiitios Chagig the implemetatio of DayOfYear requires chages to the program that uses DayOfYear A ideal class defiitio of DayOfYear could be chaged without requirig chages to the program that uses DayOfYear Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-33

34 Fixig DayOfYear To fix DayOfYear We eed to add member fuctios to use whe chagig or accessig the member variables If the program ever directly refereces the member variables, chagig how the variables are stored will ot require chagig the program We eed to be sure that the program does ot ever directly referece the member variables Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-34

35 Public Or Private? C++ helps us restrict the program from directly referecig member variables private members of a class ca oly be refereced withi the defiitios of member fuctios If the program tries to access a private member, the compiler gives a error message Private members ca be variables or fuctios Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-35

36 Private Variables Private variables caot be accessed directly by the program Chagig their values requires the use of public member fuctios of the class To set the private moth ad day variables i a ew DayOfYear class use a member fuctio such as void DayOfYear::set(it ew_moth, it ew_day) { moth = ew_moth; day = ew_day; } Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-36

37 Public or Private Members The keyword private idetifies the members of a class that ca be accessed oly by member fuctios of the class Members that follow the keyword private are private members of the class The keyword public idetifies the members of a class that ca be accessed from outside the class Members that follow the keyword public are public members of the class Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-37

38 A New DayOfYear The ew DayOfYear class demostrated i Display 10.4 Uses all private member variables Uses member fuctios to do all maipulatio of the private member variables Member variables ad member fuctio defiitios ca be chaged without chages to the program that uses DayOfYear Display 10.4 (1) Display 10.4 (2) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-38

39 Usig Private Variables It is ormal to make all member variables private Private variables require member fuctios to perform all chagig ad retrievig of values Accessor fuctios allow you to obtai the values of member variables Example: get_day i class DayOfYear Mutator fuctios allow you to chage the values of member variables Example: set i class DayOfYear Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-39

40 Geeral Class Defiitios The sytax for a class defiitio is class Class_Name { public: Member_Specificatio_1 Member_Specificatio_2 Member_Specificatio_3 private: Member_Specificatio_+1 Member_Specificatio_+2 }; Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-40

41 Declarig a Object Oce a class is defied, a object of the class is declared just as variables of ay other type Example: To create two objects of type Bicycle: class Bicycle { // class defiitio lies }; Bicycle my_bike, your_bike; Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-41

42 The Assigmet Operator Objects ad structures ca be assiged values with the assigmet operator (=) Example: DayOfYear due_date, tomorrow; tomorrow.set(11, 19); due_date = tomorrow; Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-42

43 Program Example: BakAccout Class This bak accout class allows Withdrawal of moey at ay time All operatios ormally expected of a bak accout (implemeted with member fuctios) Storig a accout balace Storig the accout s iterest rate Display 10.5 ( 1) Display 10.5 ( 2) Display 10.5 ( 3) Display 10.5 ( 4) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-43

44 Callig Public Members Recall that if callig a member fuctio from the mai fuctio of a program, you must iclude the the object ame: accout1.update( ); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-44

45 Callig Private Members Whe a member fuctio calls a private member fuctio, a object ame is ot used fractio (double percet); is a private member of the BakAccout class fractio is called by member fuctio update void BakAccout::update( ) { balace = balace + fractio(iterest_rate)* balace; } Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-45

46 Costructors A costructor ca be used to iitialize member variables whe a object is declared A costructor is a member fuctio that is usually public A costructor is automatically called whe a object of the class is declared A costructor s ame must be the ame of the class A costructor caot retur a value No retur type, ot eve void, is used i declarig or defiig a costructor Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-46

47 Costructor Declaratio A costructor for the BakAccout class could be declared as: class BakAccout { public: BakAccout(it dollars, it cets, double rate); //iitializes the balace to $dollars.cets //iitializes the iterest rate to rate percet }; //The rest of the BakAccout defiitio Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-47

48 Costructor Defiitio The costructor for the BakAccout class could be defied as BakAccout::BakAccout(it dollars, it cets, double rate) { if ((dollars < 0) (cets < 0) ( rate < 0 )) { cout << Illegal values for moey or rate\ ; exit(1); } balace = dollars * cets; iterest_rate = rate; } Note that the class ame ad fuctio ame are the same Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-48

49 Callig A Costructor (1) A costructor is ot called like a ormal member fuctio: BakAccout accout1; accout1.bakaccout(10, 50, 2.0); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-49

50 Callig A Costructor (2) A costructor is called i the object declaratio BakAccout accout1(10, 50, 2.0); Creates a BakAccout object ad calls the costructor to iitialize the member variables Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-50

51 Overloadig Costructors Costructors ca be overloaded by defiig costructors with differet parameter lists Other possible costructors for the BakAccout class might be BakAccout (double balace, double iterest_rate); BakAccout (double balace); BakAccout (double iterest_rate); BakAccout ( ); Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-51

52 The Default Costructor A default costructor uses o parameters A default costructor for the BakAccout class could be declared i this way class BakAccout { public: BakAccout( ); // iitializes balace to $0.00 // iitializes rate to 0.0% // The rest of the class defiitio }; Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-52

53 Default Costructor Defiitio The default costructor for the BakAccout class could be defied as BakAccout::BakAccout( ) { balace = 0; rate = 0.0; } It is a good idea to always iclude a default costructor eve if you do ot wat to iitialize variables Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-53

54 Callig the Default Costructor The default costructor is called durig declaratio of a object A argumet list is ot used BakAccout accout1; // uses the default BakAccout costructor BakAccout accout1( ); // Is ot legal Display 10.6 (1) Display 10.6 (2) Display 10.6 (3) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-54

55 Iitializatio Sectios A iitializatio sectio i a fuctio defiitio provides a alterative way to iitialize member variables BakAccout::BakAccout( ): balace(0), iterest_rate(0.0); { // No code eeded i this example } The values i parethesis are the iitial values for the member variables listed Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-55

56 Parameters ad Iitializatio Member fuctios with parameters ca use iitializatio sectios BakAccout::BakAccout(it dollars, it cets, double rate) : balace (dollars * cets), iterest_rate(rate) { if (( dollars < 0) (cets < 0) (rate < 0)) { cout << Illegal values for moey or rate\ ; exit(1); } } Notice that the parameters ca be argumets i the iitializatio Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-56

57 Member Iitializers C++11 supports a feature called member iitializatio Simply set member variables i the class Ex: class Coordiate { }; private:... it x=1; it y=2; Creatig a Coordiate object will iitialize its x variable to 1 ad y to 2 (assumig a costructor is t called that sets the values to somethig else) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 1-57

58 Costructor Delegatio C++11 also supports costructor delegatio. This lets you have a costructor ivoke aother costructor i the iitializatio sectio. For example, make the default costructor call a secod costructor that sets X to 99 ad Y to 99: Coordiate::Coordiate() : Coordiate(99,99) { } Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 1-58

59 Sectio 10.2 Coclusio Ca you Describe the differece betwee a class ad a structure? Explai why member variables are usually private? Describe the purpose of a costructor? Use a iitializatio sectio i a fuctio defiitio? Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-59

60 10.3 Abstract Data Types Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

61 Abstract Data Types A data type cosists of a collectio of values together with a set of basic operatios defied o the values A data type is a Abstract Data Type (ADT) if programmers usig the type do ot have access to the details of how the values ad operatios are implemeted Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-61

62 Classes To Produce ADTs To defie a class so it is a ADT Separate the specificatio of how the type is used by a programmer from the details of how the type is implemeted Make all member variables private members Basic operatios a programmer eeds should be public member fuctios Fully specify how to use each public fuctio Helper fuctios should be private members Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-62

63 ADT Iterface The ADT iterface tells how to use the ADT i a program The iterface cosists of The public member fuctios The commets that explai how to use the fuctios The iterface should be all that is eeded to kow how to use the ADT i a program Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-63

64 ADT Implemetatio The ADT implemetatio tells how the iterface is realized i C++ The implemetatio cosists of The private members of the class The defiitios of public ad private member fuctios The implemetatio is eeded to ru a program The implemetatio is ot eeded to write the mai part of a program or ay o-member fuctios Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-64

65 ADT Beefits Chagig a ADT implemetatio does require chagig a program that uses the ADT ADT s make it easier to divide work amog differet programmers Oe or more ca write the ADT Oe or more ca write code that uses the ADT Writig ad usig ADTs breaks the larger programmig task ito smaller tasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-65

66 Program Example The BakAccout ADT I this versio of the BakAccout ADT Data is stored as three member variables The dollars part of the accout balace The cets part of the accout balace The iterest rate This versio stores the iterest rate as a fractio The public portio of the class defiitio remais uchaged from the versio of Display 10.6 Display 10.7 (1) Display 10.7 (2) Display 10.7 (3) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-66

67 Iterface Preservatio To preserve the iterface of a ADT so that programs usig it do ot eed to be chaged Public member declaratios caot be chaged Public member defiitios ca be chaged Private member fuctios ca be added, deleted, or chaged Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-67

68 Iformatio Hidig Iformatio hidig was refered to earlier as writig fuctios so they ca be used like black boxes ADT s implemet iformatio hidig because The iterface is all that is eeded to use the ADT Implemetatio details of the ADT are ot eeded to kow how to use the ADT Implemetatio details of the data values are ot eeded to kow how to use the ADT Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-68

69 Sectio 10.3 Coclusio Ca you Describe a ADT? Describe how to implemet a ADT i C++? Defie the iterface of a ADT? Defie the implemetatio of a ADT? Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-69

70 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio, Ltd.. All rights reserved.

71 Iheritace Iheritace refers to derived classes Derived classes are obtaied from aother class by addig features A derived class iherits the member fuctios ad variables from its paret class without havig to rewrite them Example I Chapter 6 we saw that the class of iput-file streams is derived from the class of all iput streams by addig member fuctios such as ope ad close ci belogs to the class of all iput streams, but ot the class of iput-file streams Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-71

72 Iheritace Example Natural hierarchy of bak accouts Most geeral: A Bak Accout stores a balace A Checkig Accout IS A Bak Accout that allows customers to write checks A Savigs Accout IS A Bak Accout without checks but higher iterest Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Accouts are more specific as we go dow the hierarchy Each box ca be a class Slide 10-72

73 Iheritace Relatioships The more specific class is a derived or child class The more geeral class is the base, super, or paret class If class B is derived from class A Class B is a derived class of class A Class B is a child of class A Class A is the paret of class B Class B iherits the member fuctios ad variables of class A Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-73

74 Defiig Derived Classes Give the class ame as ormal, but add a colo ad the the ame of the base class class SavigsAccout : public BakAccout { } Objects of type SavigsAccout ca access member fuctios defied i SavigsAccout or BakAccout Display 10.9 (1-3) Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 1-74

75 Sectio 10.4 Coclusio Ca you Defie object? Defie class? Describe the relatioship betwee paret ad child classes? Describe the beefit of iheritace? Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-75

76 Chapter Ed Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-76

77 Display 10.1 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-77

78 Display 10.1 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-78

79 Display 10.2 Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-79

80 Display 10.3 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-80

81 Display 10.3 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-81

82 Display 10.4 (1/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-82

83 Display 10.4 (2/2) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-83

84 Display 10.5 (1/4) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-84

85 Display 10.5 (2/4) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-85

86 Display 10.5 (3/4) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-86

87 Display 10.5 (4/4) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-87

88 Display 10.6 (1/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-88

89 Display 10.6 (2/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-89

90 Display 10.6 (3/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-90

91 Display 10.7 (1/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-91

92 Display 10.7 (2/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-92

93 Display 10.7 (3/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-93

94 Display 10.8 Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-94

95 Display 10.9 (1/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-95

96 Display 10.9 (2/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-96

97 Display 10.9 (3/3) Back Next Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 10-97

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

Chapter 10 Defining Classes

Chapter 10 Defining Classes Chapter 10 Defining Classes What Is a Class? A class is a data type whose variables are objects Some pre-defined data types you have used are int char You can define your own classes define your own types

More information

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4

More information

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 8 Strigs ad Vectors Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Copyright 2015 Pearso Educatio, Ltd..

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to

More information

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig

More information

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig

More information

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 8 Strigs ad Vectors Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Slide 8-3 8.1 A Array Type for Strigs A Array Type for Strigs C-strigs ca be used to represet strigs

More information

Chapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 2. C++ Basics. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 2 C++ Basics Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 2.1 Variables ad Assigmets 2.2 Iput ad Output 2.3 Data Types ad Expressios 2.4 Simple Flow of Cotrol 2.5 Program

More information

CS 11 C track: lecture 1

CS 11 C track: lecture 1 CS 11 C track: lecture 1 Prelimiaries Need a CMS cluster accout http://acctreq.cms.caltech.edu/cgi-bi/request.cgi Need to kow UNIX IMSS tutorial liked from track home page Track home page: http://courses.cms.caltech.edu/courses/cs11/material

More information

Structures and Classes CS 16: Solving Problems with Computers I Lecture #15

Structures and Classes CS 16: Solving Problems with Computers I Lecture #15 Structures and Classes CS 16: Solving Problems with Computers I Lecture #15 Ziad Matni Dept. of Computer Science, UCSB WHAT THE NEXT 3 WEEKS LOOK LIKE MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY 20- Nov 21-

More information

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1 Classes ad Objects jvo@ualg.pt José Valete de Oliveira 4-1 Agai: Distace betwee poits withi the first quadrat Sample iput Sample output 1 1 3 4 2 jvo@ualg.pt José Valete de Oliveira 4-2 1 The simplest

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

From last week. Lecture 5. Outline. Principles of programming languages

From last week. Lecture 5. Outline. Principles of programming languages Priciples of programmig laguages From last week Lecture 5 http://few.vu.l/~silvis/ppl/2007 Natalia Silvis-Cividjia e-mail: silvis@few.vu.l ML has o assigmet. Explai how to access a old bidig? Is & for

More information

Java Inheritance. Class ADT (Abstract Data Type) Interface. Classes implement the concept of ADT: Interfaces define interaction contracts: Rui Moreira

Java Inheritance. Class ADT (Abstract Data Type) Interface. Classes implement the concept of ADT: Interfaces define interaction contracts: Rui Moreira Java Iheritace Rui Moreira Class ADT (Abstract Data Type) Classes implemet the cocept of ADT: Provide a coheret represetatio for the declaratio of structured data types ad also the code for maipulatig

More information

Computers and Scientific Thinking

Computers and Scientific Thinking Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput

More information

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations Chapter 14 Graph class desig Bjare Stroustrup Abstract We have discussed classes i previous lectures Here, we discuss desig of classes Library desig cosideratios Class hierarchies (object-orieted programmig)

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

Chapter 6. I/O Streams as an Introduction to Objects and Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 6. I/O Streams as an Introduction to Objects and Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 6 I/O Streams as a Itroductio to Objects ad Classes Overview 6.1 Streams ad Basic File I/O 6.2 Tools for Stream I/O 6.3 Character I/O Slide 6-3 6.1 Streams ad Basic File I/O I/O Streams I/O refers

More information

CMPT 125 Assignment 2 Solutions

CMPT 125 Assignment 2 Solutions CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address

More information

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs

CHAPTER IV: GRAPH THEORY. Section 1: Introduction to Graphs CHAPTER IV: GRAPH THEORY Sectio : Itroductio to Graphs Sice this class is called Number-Theoretic ad Discrete Structures, it would be a crime to oly focus o umber theory regardless how woderful those topics

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 3. More Flow of Control. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 3 More Flow of Cotrol Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 3.1 Usig Boolea Expressios 3.2 Multiway Braches 3.3 More about C++ Loop Statemets 3.4 Desigig Loops Copyright

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured

More information

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion Aoucemets HW6 due today HW7 is out A team assigmet Submitty page will be up toight Fuctioal correctess: 75%, Commets : 25% Last class Equality testig eq? vs. equal? Higher-order fuctios map, foldr, foldl

More information

Parabolic Path to a Best Best-Fit Line:

Parabolic Path to a Best Best-Fit Line: Studet Activity : Fidig the Least Squares Regressio Lie By Explorig the Relatioship betwee Slope ad Residuals Objective: How does oe determie a best best-fit lie for a set of data? Eyeballig it may be

More information

Threads and Concurrency in Java: Part 1

Threads and Concurrency in Java: Part 1 Cocurrecy Threads ad Cocurrecy i Java: Part 1 What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.

More information

Threads and Concurrency in Java: Part 1

Threads and Concurrency in Java: Part 1 Threads ad Cocurrecy i Java: Part 1 1 Cocurrecy What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.

More information

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup

Overview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup Chapter 18 Vectors ad Arrays Bjare Stroustrup Vector revisited How are they implemeted? Poiters ad free store Destructors Iitializatio Copy ad move Arrays Array ad poiter problems Chagig size Templates

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June CS 1313 010: Programmig for No-Majors, Summer 2007 Programmig Project #3: Two Little Calculatios Due by 12:00pm (oo) Wedesday Jue 27 2007 This third assigmet will give you experiece writig programs that

More information

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:

More information

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e)

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e) Appedix (RASD 3/e) MACIASZEK, L.A. (2007): Requiremets Aalysis ad System Desig, 3 rd ed. Addiso Wesley, Harlow Eglad ISBN 978-0-321-44036-5 Appedix Fudametals of Object Techology Pearso Educatio Limited

More information

Schema for the DCE Security Registry Server

Schema for the DCE Security Registry Server Schema for the Security egistry Server Versio Date: 0/20/00 For questios or commets cocerig this documet, sed a email ote to dce-ldap@opegroup.org or call Doa Skibbie at 52 838-3896. . Itroductio...3 2.

More information

Lecturers: Sanjam Garg and Prasad Raghavendra Feb 21, Midterm 1 Solutions

Lecturers: Sanjam Garg and Prasad Raghavendra Feb 21, Midterm 1 Solutions U.C. Berkeley CS170 : Algorithms Midterm 1 Solutios Lecturers: Sajam Garg ad Prasad Raghavedra Feb 1, 017 Midterm 1 Solutios 1. (4 poits) For the directed graph below, fid all the strogly coected compoets

More information

Last Class. Announcements. Lecture Outline. Types. Structural Equivalence. Type Equivalence. Read: Scott, Chapters 7 and 8. T2 y; x = y; n Types

Last Class. Announcements. Lecture Outline. Types. Structural Equivalence. Type Equivalence. Read: Scott, Chapters 7 and 8. T2 y; x = y; n Types Aoucemets HW9 due today HW10 comig up, will post after class Team assigmet Data abstractio (types) ad cotrol abstractio (parameter passig) Due o Tuesday, November 27 th Last Class Types Type systems Type

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis Outlie ad Readig Aalysis of Algorithms Iput Algorithm Output Ruig time ( 3.) Pseudo-code ( 3.2) Coutig primitive operatios ( 3.3-3.) Asymptotic otatio ( 3.6) Asymptotic aalysis ( 3.7) Case study Aalysis

More information

10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output

10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output File class i Java File Iput ad Output TOPICS File Iput Exceptio Hadlig File Output Programmers refer to iput/output as "I/O". The File class represets files as objects. The class is defied i the java.io

More information

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The

More information

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1 COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,

More information

top() Applications of Stacks

top() Applications of Stacks CS22 Algorithms ad Data Structures MW :00 am - 2: pm, MSEC 0 Istructor: Xiao Qi Lecture 6: Stacks ad Queues Aoucemets Quiz results Homework 2 is available Due o September 29 th, 2004 www.cs.mt.edu~xqicoursescs22

More information

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then

n The C++ template facility provides the ability to define n A generic facility allows code to be written once then UCLA PIC 10 B Problem Solvig usig C++ Programmig Ivo Diov, Asst. Prof. i Mathematics, Neurology, Statistics Istructor: Teachig Assistat: Suzae Nezzar, Mathematics Chapter 13 Templates for More Abstractio

More information

BEA WebLogic Process Integrator

BEA WebLogic Process Integrator BEA WebLogic Process Itegrator A Compoet of BEA WebLogic Itegratio BEA WebLogic Process Itegrator Studio Olie Help BEA WebLogic Process Itegrator Release 2.0 Documet Editio 2.0 July 2001 Copyright Copyright

More information

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis

n Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig

More information

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013 Code Review s Authors: Mika V. Mätylä ad Casper Lasseius Origial versio: 4 Sep, 2007 Made available olie: 24 April, 2013 This documet cotais further details of the code review defects preseted i [1]. of

More information

6.854J / J Advanced Algorithms Fall 2008

6.854J / J Advanced Algorithms Fall 2008 MIT OpeCourseWare http://ocw.mit.edu 6.854J / 18.415J Advaced Algorithms Fall 2008 For iformatio about citig these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advaced Algorithms

More information

% Sun Logo for. X3T10/95-229, Revision 0. April 18, 1998

% Sun Logo for. X3T10/95-229, Revision 0. April 18, 1998 Su Microsystems, Ic. 2550 Garcia Aveue Moutai View, CA 94045 415 960-1300 X3T10/95-229, Revisio 0 April 18, 1998 % Su Logo for Joh Lohmeyer Chairperso, X3T10 Symbios Logic Ic. 1635 Aeroplaza Drive Colorado

More information

Data Structures and Algorithms. Analysis of Algorithms

Data Structures and Algorithms. Analysis of Algorithms Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output

More information

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions

Exceptions. Your computer takes exception. The Exception Class. Causes of Exceptions Your computer takes exceptio s s are errors i the logic of a program (ru-time errors). Examples: i thread mai java.io.filenotfoud: studet.txt (The system caot fid the file specified.) i thread mai java.lag.nullpoiter:

More information

Baan Finance Financial Statements

Baan Finance Financial Statements Baa Fiace Fiacial Statemets Module Procedure UP041A US Documetiformatio Documet Documet code : UP041A US Documet group : User Documetatio Documet title : Fiacial Statemets Applicatio/Package : Baa Fiace

More information

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen COP4020 Programmig Laguages Subrouties ad Parameter Passig Prof. Robert va Egele Overview Parameter passig modes Subroutie closures as parameters Special-purpose parameters Fuctio returs COP4020 Fall 2016

More information

Abstract Syntax Trees. AST Data Structure. Visitor Interface. Accept methods. Visitor Methodology for AST Traversal CS412/CS413

Abstract Syntax Trees. AST Data Structure. Visitor Interface. Accept methods. Visitor Methodology for AST Traversal CS412/CS413 Abstract Syta Trees CS412/CS413 Itroductio to Copilers Ti Teitelbau Lecture 12: Visitors; Sybol Tables February 18, 2005 Separate AST costructio fro seatic checkig phase Traverse the AST ad perfor seatic

More information

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems

More information

1.2 Binomial Coefficients and Subsets

1.2 Binomial Coefficients and Subsets 1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Ruig Time of a algorithm Ruig Time Upper Bouds Lower Bouds Examples Mathematical facts Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite

More information

One advantage that SONAR has over any other music-sequencing product I ve worked

One advantage that SONAR has over any other music-sequencing product I ve worked *gajedra* D:/Thomso_Learig_Projects/Garrigus_163132/z_productio/z_3B2_3D_files/Garrigus_163132_ch17.3d, 14/11/08/16:26:39, 16:26, page: 647 17 CAL 101 Oe advatage that SONAR has over ay other music-sequecig

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 18 Strategies for Query Processig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio DBMS techiques to process a query Scaer idetifies

More information

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS

APPLICATION NOTE PACE1750AE BUILT-IN FUNCTIONS APPLICATION NOTE PACE175AE BUILT-IN UNCTIONS About This Note This applicatio brief is iteded to explai ad demostrate the use of the special fuctios that are built ito the PACE175AE processor. These powerful

More information

! Given the following Structure: ! We can define a pointer to a structure. ! Now studentptr points to the s1 structure.

! Given the following Structure: ! We can define a pointer to a structure. ! Now studentptr points to the s1 structure. Liked Lists Uit 5 Sectios 11.9 & 18.1-2 CS 2308 Fall 2018 Jill Seama 11.9: Poiters to Structures! Give the followig Structure: struct Studet { strig ame; // Studet s ame it idnum; // Studet ID umber it

More information

% Sun Logo for Frame. X3T10/95-229, Revision 2. September 28, 1995

% Sun Logo for Frame. X3T10/95-229, Revision 2. September 28, 1995 Su Microsystems, Ic. 2550 Garcia Aveue Moutai View, CA 94045 415 960-1300 X3T10/95-229, Revisio 2 September 28, 1995 % Su Logo for Frame Joh Lohmeyer Chairperso, X3T10 Symbios Logic Ic. 1635 Aeroplaza

More information

MOTIF XF Extension Owner s Manual

MOTIF XF Extension Owner s Manual MOTIF XF Extesio Ower s Maual Table of Cotets About MOTIF XF Extesio...2 What Extesio ca do...2 Auto settig of Audio Driver... 2 Auto settigs of Remote Device... 2 Project templates with Iput/ Output Bus

More information

Term Project Report. This component works to detect gesture from the patient as a sign of emergency message and send it to the emergency manager.

Term Project Report. This component works to detect gesture from the patient as a sign of emergency message and send it to the emergency manager. CS2310 Fial Project Loghao Li Term Project Report Itroductio I this project, I worked o expadig exercise 4. What I focused o is makig the real gesture recogizig sesor ad desig proper gestures ad recogizig

More information

CS211 Fall 2003 Prelim 2 Solutions and Grading Guide

CS211 Fall 2003 Prelim 2 Solutions and Grading Guide CS11 Fall 003 Prelim Solutios ad Gradig Guide Problem 1: (a) obj = obj1; ILLEGAL because type of referece must always be a supertype of type of object (b) obj3 = obj1; ILLEGAL because type of referece

More information

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure

More information

Evaluation scheme for Tracking in AMI

Evaluation scheme for Tracking in AMI A M I C o m m u i c a t i o A U G M E N T E D M U L T I - P A R T Y I N T E R A C T I O N http://www.amiproject.org/ Evaluatio scheme for Trackig i AMI S. Schreiber a D. Gatica-Perez b AMI WP4 Trackig:

More information

The Implementation of Data Structures in Version 5 of Icon* Ralph E. Gr is wo Id TR 85-8

The Implementation of Data Structures in Version 5 of Icon* Ralph E. Gr is wo Id TR 85-8 The Implemetatio of Data Structures i Versio 5 of Ico* Ralph E. Gr is wo Id TR 85-8 April 1, 1985 Departmet of Computer Sciece The Uiversity of Arizoa Tucso. Arizoa 85721 This work was supported by the

More information

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle:

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle: Recursio Recursio Jordi Cortadella Departmet of Computer Sciece Priciple: Reduce a complex problem ito a simpler istace of the same problem Recursio Itroductio to Programmig Dept. CS, UPC 2 Mathematical

More information

Linked Lists 11/16/18. Preliminaries. Java References. Objects and references. Self references. Linking self-referential nodes

Linked Lists 11/16/18. Preliminaries. Java References. Objects and references. Self references. Linking self-referential nodes Prelimiaries Liked Lists public class StrageObject { Strig ame; StrageObject other; Arrays are ot always the optimal data structure: A array has fixed size eeds to be copied to expad its capacity Addig

More information

why study sorting? Sorting is a classic subject in computer science. There are three reasons for studying sorting algorithms.

why study sorting? Sorting is a classic subject in computer science. There are three reasons for studying sorting algorithms. Chapter 5 Sortig IST311 - CIS65/506 Clevelad State Uiversity Prof. Victor Matos Adapted from: Itroductio to Java Programmig: Comprehesive Versio, Eighth Editio by Y. Daiel Liag why study sortig? Sortig

More information

Ch 9.3 Geometric Sequences and Series Lessons

Ch 9.3 Geometric Sequences and Series Lessons Ch 9.3 Geometric Sequeces ad Series Lessos SKILLS OBJECTIVES Recogize a geometric sequece. Fid the geeral, th term of a geometric sequece. Evaluate a fiite geometric series. Evaluate a ifiite geometric

More information

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control EE 459/500 HDL Based Digital Desig with Programmable Logic Lecture 13 Cotrol ad Sequecig: Hardwired ad Microprogrammed Cotrol Refereces: Chapter s 4,5 from textbook Chapter 7 of M.M. Mao ad C.R. Kime,

More information

Java Expressions & Flow Control

Java Expressions & Flow Control Java Expressios & Flow Cotrol Rui Moreira Expressio Separators:. [ ] ( ), ; Dot used as decimal separator or to access attributes ad methods double d = 2.6; Poto poto = ew Poto(2, 3); it i = poto.x; it

More information

MR-2010I %MktBSize Macro 989. %MktBSize Macro

MR-2010I %MktBSize Macro 989. %MktBSize Macro MR-2010I %MktBSize Macro 989 %MktBSize Macro The %MktBSize autocall macro suggests sizes for balaced icomplete block desigs (BIBDs). The sizes that it reports are sizes that meet ecessary but ot sufficiet

More information

Behavioral Modeling in Verilog

Behavioral Modeling in Verilog Behavioral Modelig i Verilog COE 202 Digital Logic Desig Dr. Muhamed Mudawar Kig Fahd Uiversity of Petroleum ad Mierals Presetatio Outlie Itroductio to Dataflow ad Behavioral Modelig Verilog Operators

More information

CIS 121. Introduction to Trees

CIS 121. Introduction to Trees CIS 121 Itroductio to Trees 1 Tree ADT Tree defiitio q A tree is a set of odes which may be empty q If ot empty, the there is a distiguished ode r, called root ad zero or more o-empty subtrees T 1, T 2,

More information

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions: CS 604 Data Structures Midterm Sprig, 00 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Istructios: Prit your ame i the space provided below. This examiatio is closed book ad closed

More information

Appendix D. Controller Implementation

Appendix D. Controller Implementation COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Appedix D Cotroller Implemetatio Cotroller Implemetatios Combiatioal logic (sigle-cycle); Fiite state machie (multi-cycle, pipelied);

More information

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only

Bezier curves. Figure 2 shows cubic Bezier curves for various control points. In a Bezier curve, only Edited: Yeh-Liag Hsu (998--; recommeded: Yeh-Liag Hsu (--9; last updated: Yeh-Liag Hsu (9--7. Note: This is the course material for ME55 Geometric modelig ad computer graphics, Yua Ze Uiversity. art of

More information

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup Note:

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup   Note: Chapter 4 Computatio Bjare Stroustrup www.stroustrup.com/programmig Abstract Today, I ll preset the basics of computatio. I particular, we ll discuss expressios, how to iterate over a series of values

More information

Analysis of Algorithms

Analysis of Algorithms Presetatio for use with the textbook, Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Aalysis of Algorithms Iput 2015 Goodrich ad Tamassia Algorithm Aalysis of Algorithms

More information

Global Support Guide. Verizon WIreless. For the BlackBerry 8830 World Edition Smartphone and the Motorola Z6c

Global Support Guide. Verizon WIreless. For the BlackBerry 8830 World Edition Smartphone and the Motorola Z6c Verizo WIreless Global Support Guide For the BlackBerry 8830 World Editio Smartphoe ad the Motorola Z6c For complete iformatio o global services, please refer to verizowireless.com/vzglobal. Whether i

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

More information

Introduction to GAMIT/GLOBK Applications of GLOBK. Lecture 11 OVERVIEW

Introduction to GAMIT/GLOBK Applications of GLOBK. Lecture 11 OVERVIEW Itroductio to GAMIT/GLOBK Applicatios of GLOBK Lecture 11 GAMIT/GLOBK Lec11 1 OVERVIEW o I this lecture we cover: o Basic types of aalyses with globk l Velocity ad repeatability rus o GLOBK acillary programs

More information

A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON

A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON A SOFTWARE MODEL FOR THE MULTILAYER PERCEPTRON Roberto Lopez ad Eugeio Oñate Iteratioal Ceter for Numerical Methods i Egieerig (CIMNE) Edificio C1, Gra Capitá s/, 08034 Barceloa, Spai ABSTRACT I this work

More information

Sharing Collections. Share a Collection via . Share a Collection via Google Classroom. Quick Reference Guide

Sharing Collections. Share a Collection via  . Share a Collection via Google Classroom. Quick Reference Guide Quick Referece Guide Share a Collectio via Email Sharig your collectio with others is a great way to collaborate. You ca easily sed a lik to your colleagues, studets, classmates ad frieds. Recipiets do

More information

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of

More information

Floristic Quality Assessment (FQA) Calculator for Colorado User s Guide

Floristic Quality Assessment (FQA) Calculator for Colorado User s Guide Floristic Quality Assessmet (FQA) Calculator for Colorado User s Guide Created by the Colorado atural Heritage Program Last Updated April 2012 The FQA Calculator was created by Michelle Fik ad Joaa Lemly

More information

CS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions

CS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions CS 111: Program Desig I Lecture # 7: First Loop, Web Crawler, Fuctios Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago September 18, 2018 What will this prit? x = 5 if x == 3: prit("hi!")

More information

Chapter 24. Sorting. Objectives. 1. To study and analyze time efficiency of various sorting algorithms

Chapter 24. Sorting. Objectives. 1. To study and analyze time efficiency of various sorting algorithms Chapter 4 Sortig 1 Objectives 1. o study ad aalyze time efficiecy of various sortig algorithms 4. 4.7.. o desig, implemet, ad aalyze bubble sort 4.. 3. o desig, implemet, ad aalyze merge sort 4.3. 4. o

More information

15-859E: Advanced Algorithms CMU, Spring 2015 Lecture #2: Randomized MST and MST Verification January 14, 2015

15-859E: Advanced Algorithms CMU, Spring 2015 Lecture #2: Randomized MST and MST Verification January 14, 2015 15-859E: Advaced Algorithms CMU, Sprig 2015 Lecture #2: Radomized MST ad MST Verificatio Jauary 14, 2015 Lecturer: Aupam Gupta Scribe: Yu Zhao 1 Prelimiaries I this lecture we are talkig about two cotets:

More information

Modern Systems Analysis and Design Seventh Edition

Modern Systems Analysis and Design Seventh Edition Moder Systems Aalysis ad Desig Seveth Editio Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Desigig Databases Learig Objectives ü Cocisely defie each of the followig key database desig terms: relatio,

More information

EE123 Digital Signal Processing

EE123 Digital Signal Processing Last Time EE Digital Sigal Processig Lecture 7 Block Covolutio, Overlap ad Add, FFT Discrete Fourier Trasform Properties of the Liear covolutio through circular Today Liear covolutio with Overlap ad add

More information

Getting Started. Getting Started - 1

Getting Started. Getting Started - 1 Gettig Started Gettig Started - 1 Issue 1 Overview of Gettig Started Overview of Gettig Started This sectio explais the basic operatios of the AUDIX system. It describes how to: Log i ad log out of the

More information