okay so i get the error that it is an invalid use of a member. The program most likely has alot of errors i just cant figure out this problem.
#include <iostream>
#include <ctime>
using namespace std;
class Time
{
public:
int current;
int currentminutes;
int currenthours;
int newcurrent;
Time()
{
current = 0;
}
Time(int newcurrent)
{
current = newcurrent;
}
double getcurrentseconds()
{
return current % 60;
}
int totalminutes()
{
return current / 60;
}
double getcurrentminutes()
{
return totalminutes % 60;
}
int totalhours()
{
totalhours = totalminutes / 60;
}
double getcurrenthours()
{
return totalhours % 24;
}
};
int main()
{
Time time();
cout << time.getcurrenthours() << ":" << time.getcurrentminutes() << ":" << time.getcurrentseconds() << endl;
Time time1(555550);
cout << time1.getcurrenthours() << ":" << time1.getcurrentminutes() << ":" << time1.getcurrentseconds() << endl;
return 0;
}
One basic point: the declaration of "time" in "main()" is wrong. You don't need "()".
Another point is: the function call is wrong. For example:
double getcurrentminutes()
{
return totalminutes % 60;
}
Should be:
double getcurrentminutes()
{
return totalminutes() % 60;
}
Try to compile them by yourself and fix the bugs by reading the compiling output.
worked perfectly thanks you so so much