|
|
Program 4 - January 29Note: This assignment was originally written in a way that was not possible to carry out in Visual C++ 6.0. It had worked well in some earlier versions, but some changes in 6.0 to put it in conformity with the C++ standard made what had previously worked ambiguous as far as the compiler was concerned. You should do this version if you are working in Visual C++. If you are working in a different compiler, I don't know whether the original will work, but it would be an interesting experiment to try it out.If you want to try the original, or just need to compare it with this one, you can see it here. The changes from the original are also highlighted on this page by use of bold italics (like this).Function OverloadingThis assignment allows you to test the use of overloading to define a function in several versions. The functions you will be writing are very simple ones but they allow you to prove that overloading works. Write a function to add two numbers and return the result. You will write four versions of this function: one for each combination of int and double. Now write functions that do the same thing for multiplication. The four function prototypes you will end up with are:
In order to see what is happening, it will be necessary for your functions to print out some information. Put a line in each of the functions similar to the following:
Here is an outline of your main program. You'll have to add some things to make it work and you can use your own numbers. int main() What to Turn InFor this assignment, you will turn in some extra material. You should send me the following:
|
|
Copyright © 2000 Charlie Poole. All rights reserved.
|