Trenton
2011-10-11 19:31:40 UTC
#include
using namespace std;
//------------------------------------------------------------------------------
class Date {
public:
enum Month {
jan=1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec
};
Date(int y, Month m, int d);
void add_day(int n);
Month month() {return m;}
int day() {return d;}
int year() {return y;}
// ...
private:
int y;
Month m;
int d; // day
};
ostream& operator<<(ostream& os, Date& d)
{
return os << d.year() << d.month() << d.day();
}
void Date::add_day(int n) {
}
//------------------------------------------------------------------------------
int main()
try
{
Date today(1995, Date::jun, 25);
//Date dx1(Year(1998), 4, 3); // error: 2nd argument not a Month
//Date dx2(Year(1998), 4, Date::mar); // error: 2nd argument not a Month
//Date dx2(4, Date::mar, Year(1998)); // error: 1st argument not a Year
//Date dx2(Date::mar, 4, Year(1998)); // error: 2nd argument not a Month
//Date dx3(Year(1998), Date::mar, 30); // ok
//This weird and unlikely error would still not be caught until run-time:
//Date dx5(Year(4), Date::mar, 1998); // run-time error: Year::Invalid
}
catch (...) {
cerr << "Oops: unknown exception!\n";
return 2;
}
//------------------------------------------------------------------------------
right now im cant even compile this without error
the error message im getting is:
:: g++ lab6_1.cpp
Undefined first referenced
symbol in file
Date::Date(int, Date::Month, int) /var/tmp//cclhhaGI.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
i really don't know what is wrong if someone has the answer it would be greatly appreciated
p.s. im on windows vista compiling with PuTTY