Here's the error:
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ios:39, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ostream:40, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/iostream:40, from date.h:15, from date.cpp:13: /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/ios_base.h: In copy constructor 'std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)': /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/ios_base.h:790: error: 'std::ios_base::ios_base(const std::ios_base&)' is private /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/iosfwd:47: error: within this context /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/iosfwd: In copy constructor 'std::basic_ostream<char, std::char_traits<char> >::basic_ostream(const std::basic_ostream<char, std::char_traits<char> >&)': /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/iosfwd:56: note: synthesized method 'std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)' first required here date.cpp: In function 'std::ostream operator<<(std::ostream&, Date&)': date.cpp:389: note: synthesized method 'std::basic_ostream<char, std::char_traits<char> >::basic_ostream(const std::basic_ostream<char, std::char_traits<char> >&)' first required here make: *** [date.o] Error 1
I think this may be due to the way my header and source file are compiled together, so here is the code for this:
Title:
#ifndef DATE_H #define DATE_H #include <iostream> using namespace std; // basic but lengthy class code #endif
A source:
//
Finally, here is the function the compiler belongs to (date.cpp: 389):
ostream operator <<(ostream &out, const Date &date) { // day out << date.day; switch (date.day) { case 1: case 21: case 31: out << "st"; break; case 2: case 22: out << "nd"; break; case 3: case 23: out << "rd"; break; default: out << "th"; break; } // month const char MONTHS[12][10] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; out << " of " << MONTHS[date.month - 1] << ", "; // year out << date.year; return out; }
I am completely puzzled here. I have Googled in the last hour, but I can not find anything that solves my problem. Thanks for any help in advance!