I would like to develop c++ application which provides day, hour, minute and second inputs from a user with setters. I am getting values from the user with setters correctly.
But I can not return value as DD:HH:MM:SS
. I coded a method called getDate
and expect to get all values in that method but it only returns the second value of Date2
object.
Here is what I tried.
#include "pch.h"
#include <iostream>
using namespace std;
class Date
{
public:
int getDate(void)
{
return day, std::string(":"), hour, std::string(":"), minute, std::string(":"), second;
}
int getDay(void) {
return day;
}
int getHour(void) {
return hour;
}
int getMinute(void) {
return minute;
}
int getSecond(void) {
return second;
}
void setDay(int a) {
day= a;
}
void setHour(int b) {
hour = b;
}
void setMinute(int c) {
minute = c;
}
void setSecond(int d) {
second = d;
}
private:
int day;
int hour;
int minute;
int second;
};
// Main function for the program
int main()
{
Date Date1;
Date Date2;
int day= 0;
int hour= 0;
int minute = 0;
int second= 0;
// Date1 specification
Date1.setDay(23);
Date1.setHour(14);
Date1.setMinute(43);
Date1.setSecond(21);
// Tarih2 specification
Date2.setDay(12);
Date2.setHour(43);
Date2.setMinute(25);
Date2.setSecond(49);
day = Date1.getDay();
cout << "Day of Date1 : " << day << endl;
hour = Date1.getHour();
cout << "Hour of Date1 : " << hour << endl;
minute = Date1.getMinute();
cout << "Minute of Date1 : " << minute << endl;
second = Date1.getSecond();
cout << "Second of Date1 : " << second << endl;
cout << "Date1 : " << Date1.getDate()<< endl;
cout << "Date2 : " << Date2.getDate()<< endl;
return 0;
}