Extraignment02
|
Overload the following operators/functions for the CAddress class as members in the program caddress04.cpp:
For each operator/function, include detailed documentation and properly indented source code. Submit the following: § Printed source code of the working program (to get any credit the function has to work) § Printed output § Self-evaluation table
The two test driver functions should be as follows: void testCAddressOperatorNotEqual(void) { cout << "testCAddressOperatorNotEqual\n"; cout << "============================\n"; for (int i=1; i<=TEST_COUNT; i++) { CAddress a1('r'), a2('r'); cout << "a1=\n"; cout << a1 << endl; cout << "a2=\n"; cout << a2 << endl; if(a1 != a2) cout << "a1 and a2 are not equal\n"; else cout << "a1 and a2 are equal\n";
a1 = a2; cout << "After a1 = a2;\n"; cout << "a1=\n"; cout << a1 << endl; cout << "a2=\n"; cout << a2 << endl; if(a1 != a2) cout << "a1 and a2 are not equal\n"; else cout << "a1 and a2 are equal\n"; cout << "-------------------------\n"; } }
void testCAddressOperatorEqual(void) { cout << "testCAddressOperatorEqual\n"; cout << "=========================\n"; for (int i=1; i<=TEST_COUNT; i++) { CAddress a1('r'), a2('r'); cout << "a1=\n"; cout << a1 << endl; cout << "a2=\n"; cout << a2 << endl; if(a1 == a2) cout << "a1 and a2 are equal\n"; else cout << "a1 and a2 are not equal\n";
a1 = a2; cout << "After a1 = a2;\n"; cout << "a1=\n"; cout << a1 << endl; cout << "a2=\n"; cout << a2 << endl; if(a1 == a2) cout << "a1 and a2 are equal\n"; else cout << "a1 and a2 are not equal\n";
cout << "-------------------------\n"; } } The output from the program should be similar to the following: testCAddressOperatorEqual ========================= a1= First Name: Dan Last Name: Rather Street: 34 Rouse Dr City: Joplin State: MO Zip: 62123 Age: 24
a2= First Name: Bob Last Name: Smith Street: 12 Joplin St City: Neosho State: AR Zip: 62123 Age: 40
a1 and a2 are not equal After a1 = a2; a1= First Name: Bob Last Name: Smith Street: 12 Joplin St City: Neosho State: AR Zip: 62123 Age: 40
a2= First Name: Bob Last Name: Smith Street: 12 Joplin St City: Neosho State: AR Zip: 62123 Age: 40
a1 and a2 are equal ------------------------- testCAddressOperatorNotEqual ============================ a1= First Name: Joe Last Name: Ray Street: 23 Broadway City: Parsons State: MO Zip: 66921 Age: 21
a2= First Name: Bob Last Name: Letterman Street: 23 Broadway City: Miami State: TX Zip: 62123 Age: 39
a1 and a2 are not equal After a1 = a2; a1= First Name: Bob Last Name: Letterman Street: 23 Broadway City: Miami State: TX Zip: 62123 Age: 39
a2= First Name: Bob Last Name: Letterman Street: 23 Broadway City: Miami State: TX Zip: 62123 Age: 39
a1 and a2 are equal -------------------------
|