Hello all. I have what should be a simple problem but I just can't get it to compile. I'm using Dev-C++ 4 on Windows 98. Basically I am creating a Date object and I want to be able to output this object with a line such as:
The file Date.h looks like this:Code:Date d(); std::cout << "Date object: " << d << std::endl;
When I try to compile this I get the following errors:Code:#ifndef Date_h #define Date_h #include <iostream> #include <string> #include <ctime> using namespace std; class Date { public: // Constructors private: // Variables // output inserter template<class charT, class Traits> friend basic_ostream<charT,Traits>& operator<<(basic_ostream<charT,Traits>& os, const Date& d); }; #endif // Date_h
Line 31 is the one that readsCode:Date.h:31: ANSI C++ forbids declaration `basic_ostream' with no type Date.h:31: template-id `basic_ostream<charT, Traits>' used as a declarator Date.h:31: `basic_ostream' is neither a function nor method; cannot be declared friend Date.h:31: invalid member template declaration `basic_ostream' Date.h:31: parse error before `&'Any help would be greatly appreciated.Code:friend basic_ostream<charT,Traits>&


Reply With Quote
