Fehler: "ostream" nicht der name einer Art

Ich bin überlastung der << und >> - operator in C++, aber kann es nicht kompilieren.

Die Fehlermeldung :" Fehler: "ostream" nicht der name ein geben"
Warum bekam ich diese Fehlermeldung? Wie es zu lösen ist?

#ifndef COMPLEX_H
#define COMPLEX_H
#include <cstdlib> //exit

#include <istream>
#include <ostream>

class Complex{
    public:
    Complex(void);
    Complex(double a, double b);
    Complex(double a);
    double real() const{ 
        return a;
    }

    double imag() const{
        return b;
    }
    friend ostream& operator<<(ostream& out,const Complex& c);
    friend istream& operator>>(istream& in, Complex& c);


    private:
    double a;
    double b;
};

ostream& operator<<(ostream& out,const Complex& c){
    double a=c.real() , b = c.imag();
    out << a << "+" << b<<"i";
    return out;
}

istream& operator>>(istream& in, Complex& c){
    in >> c.a>> c.b;
    return in;
}
#endif
InformationsquelleAutor user2741941 | 2014-10-21
Schreibe einen Kommentar