Code /* * testPerson2.cpp * CIS 250 * David Klick * 2005-02-21 * * Demonstration of friends, copy constructor, * and operator overloading. */ #include #include "person2.h" using std::cout; using std::endl; void changeName(person2 p); int main(void) { cout << "Number of objects: " << person2::getCount() << endl; person2 p1; cout << "Number of objects: " << person2::getCount() << endl; cout << p1.getName() << ' ' << p1.getSSN() << ' ' << p1.getGender() << ' ' << p1.getAge() << endl; person2 p2("Dave Klick", 123098765, 'm', -19); cout << p2.getName() << ' ' << p2.getSSN() << ' ' << p2.getGender() << ' ' << p2.getAge() << endl; changeName(p2); cout << p2.getName() << ' ' << p2.getSSN() << ' ' << p2.getGender() << ' ' << p2.getAge() << endl; cout << "Number of objects: " << person2::getCount() << endl; cout << p1 << p2 << endl; cin >> p1; p2 = p1; cout << "p1 and p2 are " << (p1==p2 ? "" : "not ") << "equal\n"; cout << p1 << p2 << endl; cout << "Number of objects: " << person2::getCount() << endl; return 0; } void changeName(person2 p) { cout << "In function - Number of objects: " << person2::getCount() << endl; p.setName("Susan Jones"); } /* Sample output Number of objects: 0 Number of objects: 1 0 M 0 Dave Klick 123098765 M 0 In function - Number of objects: 3 Dave Klick 123098765 M 0 Number of objects: 2 Name: (M) SSN: 0 Age: 0 Name: Dave Klick (M) SSN: 123098765 Age: 0 Enter name: Sam Jones Enter SSN: 123456789 Enter gender: m Enter age: 12 p1 and p2 are equal Name: Sam Jones (M) SSN: 123456789 Age: 12 Name: Sam Jones (M) SSN: 123456789 Age: 12 Number of objects: 2 */