Description
Course: CSE 165
All the exercises below are selected from the textbook: Thinking in C++ (volume 1).
1. [Exercise 19 on Page 390] Create a class (say myClass) containing both a const (say float f1) and a non-const (say const float f2) float. Initialize f1 and f2 using the constructor initializer list. [40 pts]
a. No output is needed.
b. Just ensure that your code will (1) instantiate you-defined-class in main() and (2) use the constructor initializer list to initialize the above-mentioned const and non-const floats.
2. [Exercise 16 on Page 469] Create a header file (say myHeader1.h) containing a namespace (say myNamespace). Inside the namespace create two function declarations (say fun1 and fun2). Now create a second header file (say myHeader2.h) that includes the first one (i.e., include “myHeader1.h”) and continues the namespace, adding two more function declarations (say fun3 and fun4). Now create a cpp file (say main.cpp) that includes the second header file (i.e., include “myHeader2.h”). Inside a function definition (say test1) in main.cpp, call fun1 and fun2 using a scope resolution operator. Inside a separate function definition (say test2) in main.cpp, call fun3 and fun4 using a using directive to your namespace. Inside main(), call test1 and test2. [60 pts]
a. I changed the problem description a bit to make it more actionable.
b. fun1, fun2, fun3, fun4, test1, and test2 don’t need to take any arguments and return any values.
c. No output is needed. Just ensure that your program will run smoothly.
Requirements:
* Usage of spaces, blank lines, indention, and comments for readability.
* Descriptive names of variables, functions, structs, classes, and objects (if any).
* Appropriate usage of structs, classes, and objects (if any).
Penalties:
* 5-point deduction per day late
Reviews
There are no reviews yet.