Форум программистов, компьютерный форум CyberForum.ru

std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected - C++

Восстановить пароль Регистрация
 
FanOfGun
6 / 6 / 1
Регистрация: 13.10.2012
Сообщений: 101
20.07.2013, 01:17     std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected #1
Есть класс:
C++
1
2
3
4
5
6
7
8
9
10
11
class Expression {
public:
    Expression(string expr, ErrorCallback errcb=0);
    Expression(const Expression& orig);
    virtual ~Expression();
// ..................
private:
    istream in;
    ostream out;
// .............
};
Конструкторы:
C++
1
2
3
4
5
6
7
8
9
10
Expression::Expression(const Expression& orig) {
// .........
    in=orig.in;
    out=orig.out;
}
Expression::Expression(string expr, ErrorCallback errcb) {
    this->in=istream();
    this->out=ostream();
// ...............
}
При компиляции выдает такое вот полотно:
Код
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Вход в каталог `/home/roma/NetBeansProjects/CML'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cml
make[2]: Вход в каталог `/home/roma/NetBeansProjects/CML'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/Expression.o.d
g++    -c -g -std=c++11 -MMD -MP -MF build/Debug/GNU-Linux-x86/Expression.o.d -o build/Debug/GNU-Linux-x86/Expression.o Expression.cpp
/usr/include/c++/4.7/istream: In constructor «Expression::Expression(std::string, ErrorCallback)»:
In file included from /usr/include/c++/4.7/iostream:41:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/istream:604:7: ошибка: «std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Expression.cpp:11:56: ошибка: в данном контексте
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/ostream:382:7: ошибка: «std::basic_ostream<_CharT, _Traits>::basic_ostream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Expression.cpp:11:56: ошибка: в данном контексте
In file included from /usr/include/c++/4.7/iostream:41:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/istream:604:7: ошибка: «std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Expression.cpp:15:22: ошибка: в данном контексте
Expression.cpp:15:22: ошибка: use of deleted function «std::basic_istream<char>& std::basic_istream<char>::operator=(const std::basic_istream<char>&)»
In file included from /usr/include/c++/4.7/iostream:41:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/istream:56:11: замечание: «std::basic_istream<char>& std::basic_istream<char>::operator=(const std::basic_istream<char>&)» is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.7/istream:56:11: ошибка: use of deleted function «std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)»
In file included from /usr/include/c++/4.7/ios:45:0,
                 from /usr/include/c++/4.7/ostream:40,
                 from /usr/include/c++/4.7/iostream:40,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/bits/basic_ios.h:64:11: замечание: «std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)» is implicitly deleted because the default definition would be ill-formed:
In file included from /usr/include/c++/4.7/ios:43:0,
                 from /usr/include/c++/4.7/ostream:40,
                 from /usr/include/c++/4.7/iostream:40,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/bits/ios_base.h:791:5: ошибка: «std::ios_base& std::ios_base::operator=(const std::ios_base&)» is private
In file included from /usr/include/c++/4.7/ios:45:0,
                 from /usr/include/c++/4.7/ostream:40,
                 from /usr/include/c++/4.7/iostream:40,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/bits/basic_ios.h:64:11: ошибка: в данном контексте
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/ostream:382:7: ошибка: «std::basic_ostream<_CharT, _Traits>::basic_ostream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Expression.cpp:16:23: ошибка: в данном контексте
Expression.cpp:16:23: ошибка: use of deleted function «std::basic_ostream<char>& std::basic_ostream<char>::operator=(const std::basic_ostream<char>&)»
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/ostream:56:11: замечание: «std::basic_ostream<char>& std::basic_ostream<char>::operator=(const std::basic_ostream<char>&)» is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.7/ostream:56:11: ошибка: use of deleted function «std::basic_ios<char>& std::basic_ios<char>::operator=(const std::basic_ios<char>&)»
/usr/include/c++/4.7/istream: In copy constructor «Expression::Expression(const Expression&)»:
In file included from /usr/include/c++/4.7/iostream:41:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/istream:604:7: ошибка: «std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Expression.cpp:354:46: ошибка: в данном контексте
In file included from /usr/include/c++/4.7/iostream:40:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
/usr/include/c++/4.7/ostream:382:7: ошибка: «std::basic_ostream<_CharT, _Traits>::basic_ostream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Expression.cpp:354:46: ошибка: в данном контексте
Expression.cpp:358:13: ошибка: use of deleted function «std::basic_istream<char>& std::basic_istream<char>::operator=(const std::basic_istream<char>&)»
Expression.cpp:359:14: ошибка: use of deleted function «std::basic_ostream<char>& std::basic_ostream<char>::operator=(const std::basic_ostream<char>&)»
make[2]: *** [build/Debug/GNU-Linux-x86/Expression.o] Ошибка 1
make[2]: Выход из каталога `/home/roma/NetBeansProjects/CML'
make[1]: *** [.build-conf] Ошибка 2
make[1]: Выход из каталога `/home/roma/NetBeansProjects/CML'
make: *** [.build-impl] Ошибка 2


СОБРАТЬ FAILED (значение выхода 2,, общее время: 756ms)
В чем ошибка? Заранее благодарен.

Добавлено через 2 минуты
П.с. изначально этих строк в конструкторах не было, но ошибки все равно вываливались.
Similar
Эксперт
41792 / 34177 / 6122
Регистрация: 12.04.2006
Сообщений: 57,940
20.07.2013, 01:17     std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Посмотрите здесь:

std::vector<char**> C++
C++ ошибка в программе (cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*')
error C2678: бинарный ">>": не найден оператор, принимающий левый операнд типа "std::basic_istream<_Elem,_Traits>" C++
char* vs std::string C++
IntelliSense: отсутствует оператор "<<", соответствующий этим операндам типы операндов: std::basic_ostream<char, std::char_traits<char> C++
После регистрации реклама в сообщениях будет скрыта и будут доступны все возможности форума.
Kuzia domovenok
 Аватар для Kuzia domovenok
1883 / 1738 / 116
Регистрация: 25.03.2012
Сообщений: 5,907
Записей в блоге: 1
20.07.2013, 01:33     std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected #2

Не по теме:

Ну я всегда говорил, что Линукс - ад для программиста.

C++
1
in=istream();
что тут вообще задумывалось сделать?
Tulosba
:)
Эксперт С++
4378 / 3221 / 297
Регистрация: 19.02.2013
Сообщений: 9,044
20.07.2013, 10:13     std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected #3
Kuzia domovenok, причем тут линукс вообще? Это же сообщение компилятора, а не ОС.
А проблема тут в том, что потоки нельзя копировать. Нет оператора присваивания.
Используйте инициализатор конструктора, например.
FanOfGun
6 / 6 / 1
Регистрация: 13.10.2012
Сообщений: 101
20.07.2013, 14:30  [ТС]     std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected #4
Tulosba, убрал вообще все упоминания(кроме объявления) in и out, ошибок стало меньше, но:
Код
"C:/cygwin/bin/MinGW-4.7.1/bin/make" -f nbproject/Makefile-win_debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `H:/CML'
"C:/cygwin/bin/MinGW-4.7.1/bin/make"  -f nbproject/Makefile-win_debug.mk dist/win_debug/Cygwin-Windows/cml.exe
make[2]: Entering directory `H:/CML'
mkdir -p build/win_debug/Cygwin-Windows
rm -f build/win_debug/Cygwin-Windows/Expression.o.d
g++    -c -g -std=c++11 -MMD -MP -MF build/win_debug/Cygwin-Windows/Expression.o.d -o build/win_debug/Cygwin-Windows/Expression.o Expression.cpp
c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/istream: In constructor 'Expression::Expression(std::string, ErrorCallback)':
In file included from c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/iostream:41:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/istream:604:7: error: 'std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]' is protected
Expression.cpp:11:56: error: within this context
In file included from c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/iostream:40:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/ostream:382:7: error: 'std::basic_ostream<_CharT, _Traits>::basic_ostream() [with _CharT = char; _Traits = std::char_traits<char>]' is protected
Expression.cpp:11:56: error: within this context
c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/istream: In copy constructor 'Expression::Expression(const Expression&)':
In file included from c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/iostream:41:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/istream:604:7: error: 'std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]' is protected
Expression.cpp:354:46: error: within this context
In file included from c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/iostream:40:0,
                 from Expression.h:12,
                 from Expression.cpp:8:
c:\cygwin\bin\mingw-4.7.1\bin\../lib/gcc/mingw32/4.7.1/include/c++/ostream:382:7: error: 'std::basic_ostream<_CharT, _Traits>::basic_ostream() [with _CharT = char; _Traits = std::char_traits<char>]' is protected
Expression.cpp:354:46: error: within this context
nbproject/Makefile-win_debug.mk:70: recipe for target `build/win_debug/Cygwin-Windows/Expression.o' failed
make[2]: *** [build/win_debug/Cygwin-Windows/Expression.o] Error 1
make[2]: Leaving directory `H:/CML'
nbproject/Makefile-win_debug.mk:63: recipe for target `.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `H:/CML'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
make: *** [.build-impl] Error 2


СОБРАТЬ FAILED (значение выхода 2,, общее время: 3s)
gray_fox
What a waste!
 Аватар для gray_fox
1244 / 1127 / 53
Регистрация: 21.04.2012
Сообщений: 2,350
Завершенные тесты: 3
20.07.2013, 16:01     std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected #5
FanOfGun, у istream и ostream нет конструктора по умолчанию, только конструктор преобразования из streambuf. Если
Цитата Сообщение от FanOfGun Посмотреть сообщение
убрал вообще все упоминания(кроме объявления) in и out
значит в конструторе они инициализируются конструктором по умолчанию.

Не по теме:

Цитата Сообщение от Kuzia domovenok Посмотреть сообщение
Ну я всегда говорил, что Линукс - ад для программиста.
lol что, к чему это вообще?)

Yandex
Объявления
20.07.2013, 16:01     std::basic_istream<_CharT, _Traits>::basic_istream() [with _CharT = char; _Traits = std::char_traits<char>]» is protected
Ответ Создать тему
Опции темы

Текущее время: 05:40. Часовой пояс GMT +3.
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Рейтинг@Mail.ru