a. Define constructor to initialize the data members.
b. Define two member functions input( ) to allow the user to input values for the data members.
c. Create a function of name display( ) to display the values of the data members.
Create two objects to call all the functions.
/* 16. Create a Class Time with hour, minute & second as private data members
a. Define constructor to initialize the data members.
b. Define two member functions input() to allow the user to input
values for the data members.
c. Create a function of name display() to display the values of the
data members.
Create two objects to call all the functions. */
#include<iostream.h>
#include<conio.h>
class Time
{
private:
int hour,minute,second;
public:
Time()
{
hour=minute=second=0;
}
void input()
{
cout<<"Enter hour:"<<endl;
cin>>hour;
cout<<"Enter minute:"<<endl;
cin>>minute;
cout<<"Enter second:"<<endl;
cin>>second;
}
void display()
{
cout<<endl<<"Hour:"<<hour<<endl;
cout<<"Minute:"<<minute<<endl;
cout<<"Second:"<<second<<endl;
}
};
void main()
{
clrscr();
Time obj1,obj2;
obj1.input();
obj2.input();
obj1.display();
obj2.display();
getch();
}