Академический Документы
Профессиональный Документы
Культура Документы
CS2400
Laboratory Assignment #12 and Answer Sheet
Writing classes with constructors
(60 points)
1 Introduction
In this lab, you are going to get some more practice with writing classes with constructors
and passing stream parameters as arguments to a member functions etc.
b. [5] Write the definition for the constructor with one argument.
e.[5] Write a short program (main function) to do the following. Create Counter
object with a value you choose (hint: use the constructor with one argument. Also look at
BankAccount class on pg 571-573) If the value is less than 10 increment the value
by 1. Print the original value and the incremented value.
2. Laboratory Preparation
Create a directory call Lab12 inside your 2400/Labs directory.
f. [10] Now type the above program. Save this program as lab12a.cc. Compile and
run the program to check whether you are getting the right output. If it is not correct,
correct the program before submitting electronically. The output of this program can be
Value at the beginning 5
Value at the end 6
paid
paid
paid
paid
paid
paid
N
N
N
N
N
N
Not
Not
Not
Not
Not
Not
paid
paid
paid
paid
paid
paid
Q
Q
Q
Q
Q
Q
Quit
Quit
Quit
Quit
Quit
Quit
->
->
->
->
->
->
p
p
n
p
n
q