Please check the code and output.
I've checked again and again but could not sort out the flaw.
Kindly help please!
![Logical error: I'm not getting expected result-noon-png](https://cboard.cprogramming.com/attachments/cplusplus-programming/15793d1562170209-logical-error-im-not-getting-expected-result-noon-png?s=cf06701d5f8c99e9f58a0b52b9cbdb7c)
Code:
#include<iostream>
#include<cstdlib>
using namespace std;
class Time{
private:
int hours;
int minutes;
int seconds;
public:
Time( int h, int m, int s ){
setTime(h, m, s);
}
void setTime(int h, int m, int s){
setHours(h);
setMinutes(m);
setSeconds(s);
}
void setHours(int h){
hours = (h >= 0 && h < 24) ? h : 0 ;
}
void setMinutes(int m){
minutes = (m >= 0 && m < 60) ? m : 0 ;
}
void setSeconds(int s){
hours = (s >= 0 && s < 24) ? s : 0 ;
}
int getHours() const{
return hours;
}
int getMinutes() const{
return minutes;
}
int getSeconds() const{
return seconds;
}
void printTime() const{
cout << hours << ":" << minutes << ":" << seconds << endl;
}
~Time() {
}
};
int main(){
Time wakeUp(6, 45, 0);
const Time noon(12, 0, 0);
wakeUp.printTime();
noon.printTime();
system("pause");
return 0;
}