consider two classes , hours and minutes . write a program to convert the hours to minutes using class to class type using both constructor and conversion function method
#include<iostream>
using namespace std;
class Hours{
public:
//Default constructor
float hours,minutes, seconds;
Hours(float hours){
this->hours=hours;
}
float getHoursToMinutes(float n){
minutes = n * 60;
return minutes;
}
float getHoursToSecond(float n){
seconds=n*60*60;
return seconds;
}
};
class Minutes{
float minutes, seconds;
public:
Minutes(float minutes){
this->minutes=minutes;
}
float getMinutesToSecond(float n){
seconds=minutes*60;
return seconds;
}
};
int main(){
cout<<"Conversion of hours to minutes and seconds"<<endl;
Hours h(60);
Minutes m(45);
cout<<h.getHoursToMinutes()<<endl;
cout<<m.getMinutesToSecond<()<endl;
return 0;}
Comments
Leave a comment