-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathExercise 12.2 (Completed)
30 lines (17 loc) · 1.6 KB
/
Exercise 12.2 (Completed)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1. (Practice) Enter and run Programs 12.2 and 12.3 so that you understand the relationship
between function calls in each program.
Done!!
2. (Review) Describe the difference between static binding and dynamic binding.
static binding means that the determination of which function is called is made at compile time. While dynamic binding is achieved in C++ with virtual functions.
3. (Review) Describe the difference between a virtual function and a nonvirtual function.
virtual function tells the complier to create a pointer to a function, but not fill in the pointer's value until the function is actually called.
nonvirtual functions tells the complier to create a pointer to a function, but fill in the pointer's value before the function is actually called.
4. (Review) Explain what polymorphism is and give an example of polymorphic behavior.
polymorphism allows using the same function name to invoke one response in a base class's object and another response in a derived class's objects.
An example of polymorphic behavior is any base class object that values are changed when called using the derived class object.
5. (Review) Describe the two methods C++ provides for implementing polymorphism.
Virtual functions tells the compiler to create a pointer to a function.
Operator overloading is the overloading of the default operator.
6. (Review) Explain whether the multiplication operator provided for integer and doubleprecision
built-in types is an example of overloading or polymorphism.
It is an example of overloading where the given function is assigned an operator in order to modify the resulting answer.