I'm trying to pass an auxiliary function w/in a class implementation. The compiler error I'm getting is "undefined reference to 'functionname'" in every class memeber function I call the auxiliary function from. Here's the code if anyone can help me figure this out:
Code:
// IMPLENTATION FILE FOR timetype.h
#include "timetype.h"
#include <iostream>
using namespace std;
void ConvertTime( long, int&, int&, int& );
long secsin;
TimeType::TimeType()
{
secs = 2000;
}
void TimeType::Set( /* in */ int hours,
/* in */ int minutes,
/* in */ int seconds )
{
while (hours != 24 && minutes != 0 && seconds != 0)
{
while (seconds < 60)
secs += 1;
seconds = 0;
if (minutes == 59 && hours < 24)
{
hours++;
minutes = 0;
}
else
minutes++;
}
}
void TimeType::Increment()
{
secs++;
}
void TimeType::Write() const
{
int hrs, mins, seconds;
ConvertTime( secs, hrs, mins, seconds);
if (hrs < 10)
cout << '0';
cout << hrs << ':';
if (mins < 10)
cout << '0';
cout << mins << ':';
if (seconds < 10)
cout << '0';
cout << seconds;
}
void TimeType::WriteAMorPM() const
{
int hrs, mins, seconds;
ConvertTime( secs, hrs, mins, seconds);
bool am;
int temphrs = hrs;
if (hrs > 12)
{
temphrs -= 12;
am = false;
}
if (hrs < 10)
cout << '0';
cout << temphrs << ':';
if (mins < 10)
cout << '0';
cout << mins << ':';
if (seconds < 10)
cout << '0';
cout << seconds;
if (am)
cout << "AM\n";
else
cout << "PM\n";
}
bool TimeType::Equal( /* in */ TimeType otherTime ) const
{
return (secs == otherTime.secs);
}
bool TimeType::LessThan( /* in */ TimeType otherTime ) const
{
return (secs < otherTime.secs);
}
long TimeType::Minus ( /* in */ TimeType otherTime ) const
{
if (otherTime.secs > secs)
return otherTime.secs - secs;
else
return secs - otherTime.secs;
}
void ConvertTime( /*in*/ long secsin,
/*out*/ int hrs,
/*out*/ int mins,
/*out*/ int seconds )
{
while (secsin != 0)
{
if (secsin > 60)
{
for (int i = 0; i < 60; i++)
{
seconds++;
secsin--;
}
if (mins == 59)
{
hrs++;
mins = 0;
}
else
mins++;
seconds = 0;
}
else
seconds++;
}
}