operator<< überladen



  • hi,
    hab ein problem bei der überladung des operators "<<" für die cout ausgabe. wies geht is klar. mir gehts eher um die fehlermeldung die für mich keinen sinn macht.

    ISO C++ forbids declaration of ostream' with no typeostream' is neither function nor member function; cannot be declared friend
    parse error before `&' token

    compiler dev-cpp 4.9.8.7 mit gcc version 3.2

    friend ostream &operator<<(ostream &os, String &src);
    

    diese meldung kommt allein durch die deklaration des prototyps.
    an was liegts?

    thx & bye



  • Hast du <ostream> oder besser <iosfwd> eingebunden?
    Ersetz mal ostream durch std::ostream.



  • hat sich erledigt thx...
    hät ich selbst auch drauf kommen können ...


Anmelden zum Antworten