This is a pretty easy program but its failing saying:
Code:
Undefined symbols for architecture x86_64:
Code:
"CheapWatch::CheapWatch()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am not even sure what this even means.
Code:
#include <iostream>
#include <ctime>
using namespace std;
class CheapWatch {
private:
int hours;
int minutes;
int seconds;
public:
CheapWatch();
void set_values(int);
int NumSeconds();
void LocalTime();
};
void CheapWatch::set_values ( int Secs ) {
hours = Secs / 3600;
minutes = (Secs % 3600) / 60;
seconds = Secs % 60;
}
int CheapWatch::NumSeconds()
{
return ((hours * 3600) + (minutes * 60) + seconds); //returns number seconds since midnight to confirm
}
void CheapWatch::LocalTime()
{
time_t now = time(0);
char* t = ctime(&now);
cout<<"The current time is: "<<t<<endl;
}
int main()
{
CheapWatch watch;
int sec;
cout<<"How how many seconds after midnight have passed? "<<endl;
cin>>sec;
watch.set_values(sec);
cout<<"You have entered "<<sec<<"Which means"<<watch.NumSeconds()<<"Seconds has passed\n";
cout<<"Your local time is: ";
watch.LocalTime();
return 0;
}