Homework #1

1. Write several versions of an overloaded function called AddEm. The main function demonstrated below shows how the AddEm function is to be used, it is up to you to determine how many overloaded functions you must write, and how to write them. The purpose of the AddEm function is to add two values and return the result.

2. Write a function called ShowMessage. It is not overloaded, but it should accept two parameters of char * type named Msg and Caption. If Caption is anything but NULL, it is output first, followed by a new line and a tab character. Msg is always output, whether Caption was NULL or not. The Caption parameter should default to NULL.

3. Write a class called HomeWork. In this class, you must write a contructor that takes no parameters, and you must write a destructor. The constructor should simply output the text In HomeWork::ctor and the destructor should simply output the text In HomeWork::dtor.

The following is a test main function for your assignment:

int main()
	int Result;
	HomeWork X;
	Result = AddEm( 1, "3" );
	cout << "Test 1: " << Result << endl;
	Result = AddEm( "3", 1 );
	cout << "Test 2: " << Result << endl;
	Result = AddEm( "3", "1" );
	cout << "Test 3: " << Result << endl;
	Result = AddEm( 1, 3 );
	cout << "Test 4: " << Result << endl;
	ShowMessage("Test without Caption" );
	// Note: Test below will print "The Caption", then "Test with Caption"
	ShowMessage("Test with caption", "The Caption" );


The following is sample output from the program:

In Homework::ctor
Test 1: 4
Test 2: 4
Test 3: 4
Test 4: 4
Test without Caption
The Caption:
	Test with caption
In Homework::dtor

Hand in a printout of only your .cpp file, and .h file if you created one. For this assignment, you needn't make a separate .h file for your class or prototypes, they may be all in one .cpp file.

Please make sure to place your name, the date, and class name at the top of your handed-in homeworks.