I am having a hard time linking my header file with my cpp file.
My header file time24.h is as follows:
#ifndef time24_h
#define time24_h
class time24
{
public:
time24(int h = 0, int m = 0);
// Constructor initializes hour and minute
void addTime(int m);
//update time by adding m minutes to the current time
//Precondition: m must be >=0
time24 duration(const time24& t);
// return the length of time from some current time to some later time
// time t as a time24 value
void readTime();
// Reads in time from keyboard in hh:mm format
//Postcondition: Assign value hh to hour and mm to minute
// normalize time
void writeTime() const;
//display the time on screen in HH:MM format
//ACCESS MEMBER FUNCTIONS
int getHour()const;
// return the hour value for the current time
int getMinute()const;
//return the minute value for the current time
private:
int hour,minute; //data members
void normalizeTime();
// Utility function that sets the hours value in the range 0 -23
// and the minute value in the range 0 - 59
};
#endif
And then my class implementations are in my time24.cpp file
which is as follows:
#include <iostream>
#include "time24.h"
using namespace std;
//FUNCTION normalizeTime(): Sets hours and minutes within their proper ranges
void time24::normalizeTime()
{
int extraHours = minute/60;
//set minutes in range from 0 to 59
minute %=60;
//Update hour. Set in range 0-23
hour = (hour + extraHours) % 24;
}
// CONSTRUCTOR: creates time 24 object with initial arguments h and m
time24::time24(int h , int m):hour(h),minute(m)
{
//put hour and minute in the correct range
normalizeTime();
}
//FUNCTION duration(): returns time24 object with difference in time in
//minutes
time24 time24:uration(const time24& t)
{
//convert currTime and time t to minutes
int currTime = (hour * 60)+minute;
int tTime = (t.hour*60)+t.minute;
// return anonymous object
return time24(0,tTime-currTime);
}
//FUNCTION readTime(): reads in time from keyboard
void time24::readTime()
{
char delimeter;
cin>>hour>>delimeter>>minute;
//make sure hour and minute are in range
normalizeTime();
}
//FUNCTION getHour():Accesses private data member hour
int time24::getHour()const
{
return hour;
}
//FUNCTION getMinute(): Accesses private data member minute
int time24::getMinute()const
{
return minute;
}
//FUNCTION writeTime(): displays time24 object in HH:MM format on screen
void time24::writeTime()const
{
cout<<hour<<":"<<minute<<endl;
}
//Function addTime(int m): adds m number of minutes to a time24 object
void time24::addTime(int m)
{
minute += m;
normalizeTime();
}
Ive reviewed my work several times and cant figure out while my files wont link ....
I recieve the following errors
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib DYLAN
Error 2 fatal error LNK1120: 1 unresolved externals C:\Documents and Settings\dh63265\My Documents\Visual Studio 2008\Projects\DYLAN\Debug\DYLAN.exe DYLAN
Ive tried googling these errors and tried the necessary fixes I could find but messing with linker advanced properties which was usually the recommended fix did not work.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.