000
04.12.2003, 16:28 Uhr
~nAvi
Gast
|
Ich möchte eine Funktion schreiben die einen Stream öffnet und diesen zurückgibt. Mein Quellcode sieht so aus
C++: |
ifstream open_it(int count,char *args[]) { ifstream txt;
if(count < 2) error("Keine Datei zum oeffnen angegeben!");
txt.open(args[2],ios_base::in);
if(!txt) error("Konnte Datei nicht oeffnen!");
return txt; }
int main(int argc,char *argv[]) { ifstream test; test = open_it(argc,argv); }
|
Ich bekomme aber nur einen Fehler beim Kompelieren. Was is da falsch? So sieht meine Fehlermeldung aus:
Compiler: Default compiler Führt g++.exe... aus g++.exe "Cschema\get_shape.cpp" -o "Cschema\get_shape.exe" -I"CDev-Cpp\include\c++" -I"CDev-Cpp\include\c++\mingw32" -I"CDev-Cpp\include\c++\backward" -I"CDev-Cpp\include" -L"CDev-Cpp\lib" C:/Dev-Cpp/include/c++/bits/ios_base.h: In copy constructor `std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&': C:/Dev-Cpp/include/c++/bits/ios_base.h:421: `std::ios_base::ios_base(const std::ios_base&' is private C:/schema/get_shape.cpp:33: within this context
C:/Dev-Cpp/include/c++/streambuf: In copy constructor `std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf(const std::basic_filebuf<char, std::char_traits<char> >&': C:/Dev-Cpp/include/c++/streambuf:486: `std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>& [with _CharT = char, _Traits = std::char_traits<char>]' is private C:/schema/get_shape.cpp:33: within this context
C:/Dev-Cpp/include/c++/bits/ios_base.h: In member function `std::basic_ios<char, std::char_traits<char> >& std::basic_ios<char, std::char_traits<char> >::operator=(const std::basic_ios<char, std::char_traits<char> >&': C:/Dev-Cpp/include/c++/bits/ios_base.h:424: `std::ios_base& std::ios_base::operator=(const std::ios_base&' is private C:/schema/get_shape.cpp:42: within this context
C:/Dev-Cpp/include/c++/streambuf: In member function `std::basic_filebuf<char, std::char_traits<char> >& std::basic_filebuf<char, std::char_traits<char>
>::operator=(const std::basic_filebuf<char, std::char_traits<char> >&': C:/Dev-Cpp/include/c++/streambuf:489: `std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const std::basic_streambuf<_CharT, _Traits>& [with _CharT = char, _Traits = std::char_traits<char>]' is private C:/schema/get_shape.cpp:42: within this context
Ausführung beendet |