Presentation is loading. Please wait.

Presentation is loading. Please wait.

HW 5.

Similar presentations

Presentation on theme: "HW 5."— Presentation transcript:

1 HW 5

2 Overview Try/catch framework is required for main function
Please indent your files rightly I suggest that you try all examples on the book if you find it difficulty to go on with homework Do not wait for the last moment to ask for help, have a schedule for each problem ahead.

3 PR 1 First run :: ./a.out There were 99 0's. There were 119 1's. There were 118 2's. There were 98 3's. There were 87 4's. There were 105 5's. There were 94 6's. There were 94 7's. There were 102 8's. There were 84 9's. Second run :: ./a.out There were 97 0's. There were 100 1's. There were 99 2's. There were 87 3's. There were 107 4's. There were 104 5's. There were 104 6's. There were 96 7's. There were 93 8's. There were 113 9's.

4 PR 1 You will write three files, randint.h, randint.cpp, hw5pr1.cpp
Source code for randint.cpp is given Why and how to write code in separate files. P.51 on text book about linking How to compile multiple source code. g std=c++11 hw5pr1.cpp randint.cpp

5 PR 2 output: 1:OK 2:DIFF 3:DIFF 4:DIFF
file1: abc def g h i file2: DEf ghi uub output: 1:OK 2:DIFF 3:DIFF 4:DIFF

6 PR 2 Read and Write file, see Chapter 10.4 & 10.5 on text book
Use getline(…) function string str; ifstream file("file.dat"); While(getline(file, str)) { // do something here }

7 PR 3 Input Input (2000,1,2) (2000,12,31) Output Output (2000,1,3)

8 PR 3 Based on Chrono.h and Chrono.cpp of section 9.8.
Add dummy “return d” in the last 3 functions on page 332 to make the code compiles OK. Add ++ operator overload to class Data type putting the declaration in the Date class in Chrono.h and the definition in Chrono.cpp.

9 PR 3 Pseudocode for ++ overload is Date& operator++(){
//add 1 to d //tomorrow, unless we were at the end of the month //if is_date is false // //need to change to first of next month // set d to 1 // if m is December // //need to change to next year too // set m to January // increment y // else // increment m return *this; }

10 More about prefix and suffix ++ overload, see this page

Download ppt "HW 5."

Similar presentations

Ads by Google