This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: how come #include "*.cpp" works?
- From: clayne at anodized dot com
- To: cygwin at cygwin dot com
- Cc: klaas dot thoelen at telenet dot be
- Date: Thu, 11 May 2006 16:52:16 -0700
- Subject: Re: how come #include "*.cpp" works?
- References: <44638BED.5020009@telenet.be>
On Thu, May 11, 2006 at 09:09:33PM +0200, Klaas Thoelen wrote:
>
> This seems a little strange to me. Does anybody know what's wrong here?
>
> Thanks and regards,
> Klaas Thoelen
It's just a classic mistake, pretty easily fixed with the following:
> datum.h
> ******
Add this:
#ifndef DATUM_H
#define DATUM_H
> class Date {
> public:
> Date();
> Date(int dd, int mm, int yy);
> int day();
> int month();
> int year();
> static void set_default(int, int, int);
> Date& add_year(int);
> Date& add_month(int);
> Date& add_day(int);
> Date& print();
> private:
> int d, m, y;
> static Date default_date;
> static bool is_leapyear(int);
> static int daysinmonth(int, int);
> };
#endif /* DATUM_H */
That ifndef construct is a one-way trap-door to prevent a doubly included file
from clobbering itself. Pretty standard.
>
> datum.cpp
> ********
> #include "datum.h"
Probably should place this after your standard includes below.
> #include <iostream>
> #include <assert.h>
> using namespace std;
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/