| Overview | This assignment will help you learn how to implment functions in seperate files from your main source code file and introduce you to the use of "Make" for compiling your programs. Specifically, you will write a function called "myCopyRight". You will write the declaration into a file called myCopyRight.h and the function definition will be written in a file with the name myCopyRight.cpp. The instruction for using "Make" will be discussed in lecture. To demonstrate the use of your new compyright function you will also need to write a driver program to test your function | |
|---|---|---|
| Set up for the Assignment |
To get the make file and get set up do the following. First update (if necessary) the shared files: login in to loki cd # Go to home dir cd cs23021_shared # Go into shared working copy svn update # Get update from repository Then create the directory and copy the files: cd # Go to home dir cd cs23021 # Go into your working copy svn mkdir HW4 # Make dir for HW4 cd HW4 # Go into new dir cp ../../cs23021_shared/HW4/makefile . # Copy makefile from shared to current dir cp ../../cs23021_shared/HW4/myCopyright.h . # Copy myCopyright.h from shared to current dir cp ../../cs23021_shared/HW4/myCopyright.cpp . # Copy myCopyright.cpp from shared to current dir cp ../../cs23021_shared/HW4/driver.cpp . # Copy driver.cpp from shared to current dir svn add makefile # Add to versioning svn add myCopyright.h # Add to versioning svn add myCopyright.cpp # Add to versioning svn add driver.cpp # Add to versioning svn commit -m "set up for hw4 done" # Commit |
|
| Part 1. | In the file myCopyright.h write a function declaration for the function that you will implement in the file myCopyright.cpp. This function should have one formal parameter that will be used to pass the name of the program from the calling program. | |
| Part 2. |
In the file myCopyright.cpp write a function that prints out a copyright statement like the example shown below. The name of the program will be passed into the function as a string parameter.
******************************************************************************* * This program "program name" is the property of YOUR NAME * * (c)Copyright 2006 YOUR NAME, All Rights Reserved. * ******************************************************************************* | |
| Part 3. |
In the file driver.cpp write a program that calls your myCopyright function and then prints out the following text:
This is a test driver program to test the implementation of myCopyright function, the name of this program is "program name".This test program should print out the actual program name in place of "program name" in the above text. | |
| Requirements | The general program requirements apply. | |
| Turning In | Make sure your files are in the repository. |