/* Example of creating and using a namespace. John Sterling CS1124 Polytechnic University */ // This is based on the same code as was used in the earlier program // to implement and test the Date class in separate compilation. // Comments have generally been removed these files if they don't relate // to creating/using our namespace. #include "Date.h" #include #include using namespace std; // In Date.h and Date.cpp we called our namespace ASillyName // Note that we use our own namespace the same way that we // use std. using namespace ASillyName; int main() { Date d1("03/14/1592"); cout << "d1's year is: " << d1.getYear() << endl; cout << "Change d1's year to 17\n"; d1.setYear(17); cout << "Checking d1's year: " << d1.getYear() << endl; cout << "Displaying d1: "; d1.display(); cout << endl; cout << "Displaying d2: "; Date d2("11/23/5813"); d2.display(); cout << endl; cout << "Is date d1 earlier than date d2?\n"; if (d1.earlierThan(d2)) cout << "Yes\n"; else cout << "No\n"; }