C++

h2o
lab14.cpp

#include<iostream> #include<iomanip> using namespace std; //DATE CLASS DECLARATION class Date { public: Date(int m, int d, int y); //constructor void display(); private: int month; int day; int year; }; //TIME CLASS DECLARATION class Time { public: Time(int h, int m); //constructor void display(); private: int hour; int minute; }; //DATE CLASS DEFINITION Date::Date(int m, int d, int y) //constructor : month(m), day(d), year(y) //initialization list { } void Date::display() { cout << month << '/' << day << '/' << year << endl; } //TIME CLASS DEFINITION Time::Time(int h, int m) //constructor : hour(h), minute(m) //initialization list { } void Time::display() { cout << hour << ':' << setw(2) << setfill('0') << minute << endl; setfill(' '); } //OTHER FUNCTIONS (none in this case), AND THE MAIN-FUNCTION int main() { Date d(7,4,1776); Time t(12,3); d.display(); t.display(); }