error: Kein Zugriff auf protected Element
-
Ich hab ein kleines Problem:
ich wollte eine ostream-func für meine klasse schreiben. jetzt sagt der mir aber, dass ich keinen zugriff auf protected element habe...(benutze vc++)#ifndef bool_array_h_ #define bool_array_h_ #include <iostream.h> class bool_array { public: bool_array():length(0){array = NULL;} bool_array(int index); bool_array(bool state, int index); const bool& operator[](int index){return array[index];} const int Length(){return length;} bool *Array(){return array;} private: bool *array; int length; }; bool_array::bool_array(int index): length(index) { array = new bool[index]; for (int i = 0; i < length; i++) array[i] = false; } bool_array::bool_array(bool state, int index): length(index) { array = new bool[index]; for (int i = 0; i < length; i++) array[i] = state; } ostream operator<<(ostream& stream, bool_array& barr) { for (int i = 0; i < barr.Length(); i++) { if (barr[i]) stream << "1"; else stream << "0"; } return stream; //<<-- DA WILL ER NICHT WEITER } #endif
Fehlermeldung ist:
--------------------Konfiguration: wenig - Win32 Debug-------------------- Kompilierung läuft... wenig.cpp c:\programme\microsoft visual studio\myprojects\wenig\bool_array.h(48) : error C2248: "ostream::ostream" : Kein Zugriff auf protected Element, dessen Deklaration in der Klasse "ostream" erfolgte c:\programme\microsoft visual studio\vc98\include\ostream.h(100) : Siehe Deklaration von 'ostream::ostream' Fehler beim Ausführen von cl.exe. wenig.exe - 1 Fehler, 0 Warnung(en)
hab schon im forum gesucht, aber soweit nichts gefunden...
wenn mir da jemand helfen könnte wären ganz net
-
du darfst streams nicht kopieren
-
ja und wie sollt ich des dann machen????
-
referenz
-
thx
ich bin ja uch ein schussel