goncrazybbaksoon
Programmer
I'm getting parse errors on three lines, and I don't see anything wrong with them. I haven't put the code in to display the time yet, so disregard that. The parse errors are on these lines:
Clock.addseconds(int sec);
Clock.pm('P');
Clock.pm('A');
Can anybody tell me what the problem is?
The whole code is below:
//Clock
#include <iostream.h>
#include <stdlib.h>
class Clock //new data type
{
public:
void addseconds(int sec);
void showtime(char ampm);
Clock()
{
hour = 12;
min = sec = 0;
pm = false;
}
private:
int sec; //00-59 seconds
int min; //00-59 minutes
int hour; //1-12 hours
bool pm; //am or pm
};
int main()
{
Clock clock;
Clock ampm;
for(int i=0; i<86400; i++)
{
Clock.addseconds(int sec);
Clock.showtime(char ampm);
}
cout<<":";
system("PAUSE"
;
return 0;
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void Clock::addseconds(int sec)
{
if(sec < 59)
{
sec++;
}
else
{
sec = 0;
if(min < 59)
{
min++;
}
else
{
min = 0;
if(hour < 12)
{
hour++;
}
else
{
hour = 1;
if(hour==12)
{
pm = true; //change to pm
}
}
}
}
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void Clock::showtime(char ampm)
{
char pm;
if(pm==true)
{
Clock.pm('P');
}
else
{
Clock.pm('A');
}
}
Clock.addseconds(int sec);
Clock.pm('P');
Clock.pm('A');
Can anybody tell me what the problem is?
The whole code is below:
//Clock
#include <iostream.h>
#include <stdlib.h>
class Clock //new data type
{
public:
void addseconds(int sec);
void showtime(char ampm);
Clock()
{
hour = 12;
min = sec = 0;
pm = false;
}
private:
int sec; //00-59 seconds
int min; //00-59 minutes
int hour; //1-12 hours
bool pm; //am or pm
};
int main()
{
Clock clock;
Clock ampm;
for(int i=0; i<86400; i++)
{
Clock.addseconds(int sec);
Clock.showtime(char ampm);
}
cout<<":";
system("PAUSE"
return 0;
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void Clock::addseconds(int sec)
{
if(sec < 59)
{
sec++;
}
else
{
sec = 0;
if(min < 59)
{
min++;
}
else
{
min = 0;
if(hour < 12)
{
hour++;
}
else
{
hour = 1;
if(hour==12)
{
pm = true; //change to pm
}
}
}
}
}
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
void Clock::showtime(char ampm)
{
char pm;
if(pm==true)
{
Clock.pm('P');
}
else
{
Clock.pm('A');
}
}