I have a program that was given to us from our teacher. I am having trouble compiling it. I keep getting an error during the compile. The error message says: The compiler could not find the named file. It stops on unable to open include file 'DATE.H'.
I am Using Borland C++ 5.02. I pasted the code below, hopefully it helps.
Code:
/**Date.cc implements Date class**/
#include <iostream>
#include "Date.h"
using namespace std;
Date::Date(unsigned m, unsigned d, unsigned y)
{
month = m;
day = d;
year = y;
}
void Date::Display(ostream & out) const
{
out <<month<<'-'<<day<<'-'<<year;
}
bool Date::operator<(const Date & dt) const
{
if (year < dt.year)
return true;
else if (year == dt.year)
{
if (month < dt.month)
return true;
else if (month == dt.month)
{
if (day < dt.day)
return true;
}
}
return false;
}
/** Date.h -------------------------------------**/
#include <iostream>
using namespace std;
class Date
{
/******** Member functions ********/
public:
Date();
Date(unsigned initMonth, unsigned initDay, unsigned initYear);
void Display(ostream & out) const;
unsigned getMonth() {return month;}
unsigned getDay() {return day;}
unsigned getYear() {return year;}
void setMonth(unsigned m) {month = m;}
void setDay(unsigned d) {day = d;}
void setYear(unsigned y) {year = y;}
bool operator<(const Date & dt) const;
/********** Data Members **********/
private:
unsigned month, day, year;
}; // end of class declaration
//----- Definition of default constructor
inline Date::Date()
{
month = 1;
day = 1;
year = 2000;
}
/**Test Date.cc, Date.h**/
#include <iostream>
#include "Date.h"
void main()
{
Date now, then;
now.setMonth(9);
now.setDay(1);
now.setYear(2002);
then.setMonth(11);
then.setDay(15);
then.setYear(1988);
cout<<"\nIt is now ";
now.Display(cout);
cout<<endl;
if (now < then)
cout<<"\nNow is before then\n";
else
cout<<"\nNow is not before then\n";
}
[code tags added by ygfperson]
Thanks.....