Thread: header files

  1. #1
    Registered User
    Join Date
    Sep 2002

    header files

    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.

    /** 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 <
          return true;
     return false;
    /** Date.h -------------------------------------**/
    #include <iostream>
    using namespace std;
    class Date
    /******** Member functions ********/
    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 **********/
     unsigned month, day, year;
    }; // end of class declaration
    //----- Definition of default constructor
    inline Date::Date()
     month = 1;
     day = 1;
     year = 2000;
    /**Test, Date.h**/
    #include <iostream>
    #include "Date.h"
    void main()
     Date now, then;
     cout<<"\nIt is now ";
     if (now < then)
      cout<<"\nNow is before then\n";
      cout<<"\nNow is not before then\n";
    [code tags added by ygfperson]

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    You have this split into 3 separate files right?
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    This doesn't answer your question, but have a read of this one.

    Also, void main is wrong, use int main and return 0; at the end.

    >You have this split into 3 separate files right?
    ... in the same directory as each other....?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. #include header files or .cpp files?
    By DoctorX in forum C++ Programming
    Replies: 3
    Last Post: 12-23-2006, 12:21 PM
  3. classes and header files
    By Drake in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2006, 07:12 PM
  4. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM