Compile error when defining overloaded friend operator?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mwatson
    New Member
    • Feb 2008
    • 2

    Compile error when defining overloaded friend operator?

    Hey I'm trying to compile a project for class (C++/linux) but I can't figure out what this g++ error means:

    time.h:22: error: ISO C++ forbids declaration of 'istream' with no type
    time.h:22: error: 'istream' is neither function nor member function; cannot be declared friend
    time.h:22: error: expected ';' before '&' token

    The code it's referencing is a public function definition:
    Code:
    #include <iostream>
    
    class Time
    {
      private:
        int hour, minute;
        bool am;
        Time() {};
        friend class Appointment;
    
      public:
        Time(int, int, bool);
        int getHour();
        int getMinute();
        bool isAM();
        bool operator<(Time);
        [B]friend istream& operator>>(istream& istr, Time t);[/B]
    };
    Shouldn't istream be defined in the iostream header file?

    Thanks in advance for any help, and let me know if more info is needed.
  • mwatson
    New Member
    • Feb 2008
    • 2

    #2
    Dumb mistake on our part - forgot the using namespace std;

    Comment

    Working...