База ответов ИНТУИТ

Программирование на С/С++

<<- Назад к вопросам

<pre> //====================== start of sample.cpp ========================== struct A { A(); virtual ~A(); private: A(A&amp;a); A&amp; operator=(const A&amp; a); }; struct B: public A {}; struct C {}; struct D { D(); D&amp; operator=(const D&amp; d); }; //====================== end of sample.cpp ========================== </pre> Какие из типов из файла sample.cpp удовлетворяют требованию CopyConstructible?

(Ответ считается верным, если отмечены все правильные варианты ответов.)

Варианты ответа
B
D(Верный ответ)
C(Верный ответ)
A
Похожие вопросы
<pre> //====================== start of sample.h ========================== struct A {}; struct B; struct B *pb = 0; struct A *pa = 0; struct B b; struct A a; void foo(const struct B&amp; in_b); //====================== end of sample.h ========================== </pre> Какие присвоения и объявления в файле sample.h валидны?
<pre> //====================== start of sample.cpp ========================== struct A {}; struct B {}; struct C {}; struct D {}; struct E {}; struct F {}; int main() { try { foo(); } catch(const A&amp; a) {} catch(static const B*) {} catch(C c) {} catch(volatile D* d) {} catch(virtual E* e) {} catch(F*&amp;) {} catch(...) { return 5; } return 0; } //====================== end of sample.cpp ========================== </pre> Обработчики исключений какого типа записаны неправильно?
<pre> //====================== start of sample.cpp ========================== #include &lt;boost/variant/variant.hpp&gt; struct A {}; struct B { B(int src); private: B(const B&amp; src); }; struct C { C(int src); private: C(); }; struct D {}; int main(int argc, char* argv[]) { boost::variant&lt;int, A, B, C&gt; myvariant; int x; int* y; A a; B b(x); C c(x); D d; myvariant = x; myvariant = y; myvariant = a; myvariant = b; myvariant = c; myvariant = d; return 0; } //====================== end of sample.cpp ========================== </pre> Какие объекты можно присвоить объекту myvariant из примера в файле sample.cpp?
<pre> //====================== start of sample.cpp ========================== struct A {}; struct B; struct B *pb = new B; struct A *pa = new A; struct B b = *pb; class C { struct B m_b; }; class D { struct A m_a; }; //====================== end of sample.cpp ========================== </pre> Какие присвоения и объявления в файле sample.cpp валидны?
<pre> //====================== start of sample.h ========================== struct S_EMPTY {}; struct A { int i; double g; }; class B { long jj; public: char _str[6]; private: static char str_4_all[9]; }; union mytypes_t { int i; float f; } My; //====================== end of sample.h ========================== </pre> Доступ к каким из членов класса, описанных в файле sample.h (выше), является открытым?
<pre> //====================== start of sample.h ========================== struct S_EMPTY {}; struct A { int i; double g; }; class B { long jj; public: char _str[6]; private: static char str_4_all[9]; }; union mytypes_t { int i; float f; } My; //====================== end of sample.h ========================== </pre> Доступ к каким из членов класса, описанных в файле sample.h (выше), является закрытым?
<pre> //====================== start of sample.cpp ========================== struct A {}; struct B {}; struct C {}; struct D {}; struct E {}; struct F {}; void foo(int i) try { switch(i) { case 1: throw A(); case 2: throw B(); case 4: throw D(); default: throw F(); } } catch(A&amp;) { } catch(B&amp;) { throw D(); } catch(D&amp;) { throw C(); } catch(...) { throw; } int main(int argc, char* argv[]) { try { foo(argc); } catch(const A&amp; a) {} catch(const B*) {} catch(C c) {} catch(E* e) {} catch(...) { return 5; } return 0; } //====================== end of sample.cpp ========================== </pre> При каких значении argc программа вернёт значение 5?
<pre> //====================== start of sample.cpp ========================== struct A {}; struct B {}; struct C {}; struct D {}; struct E {}; struct F {}; class BaseIO { public: virtual int state() throw(A) = 0; virtual void read() throw(A, B) = 0; virtual void write() throw (C, D) = 0; virtual void open() throw (E,F) = 0; virtual void close() throw() = 0; }; class DiskIO: public BaseIO { public: virtual int state() throw(); virtual void read() throw (A, B); virtual void write() throw (C); virtual void open() throw (A, E); virtual void close() throw (F); }; //====================== end of sample.cpp ========================== </pre> Перегрузка каких виртуальных методов базового класса в классе DiskIO выполнена корректно?
<pre> //====================== start of sample.cpp ========================== template &lt;typename T&gt; class multiplies: public binary_function&lt;T,T,T&gt; { public: T operator() (const T&amp; x, const T&amp; y) const { return x * y; } }; //====================== end of sample.cpp ========================== </pre> Какие утверждения про приведённый выше код функтора multiplies верны?
<pre> //====================== start of sample.cpp ========================== class ARef { public: ARef(A &amp;a, int i) : _a(a), _ix(i) {} ARef&amp; operator= (T t) { return *this;} operator T() {return _t;} operator A() {return _a;} A& getA() { return _a;} bool operator == (A&amp; a) {return _a == a;} private: A&amp; _a; int _ix; T _t; }; class A { friend class ARef; public: A() {} ARef operator[] (int ix) {return ARef(*this, ix);} operator ARef() {return ARef(*this, ix);} }; //====================== end of sample.cpp ========================== </pre> Какие из методов класса ARef из файла sample.cpp являются необходимыми для поддержки идиомы контекстно-зависимой перегрузки операции индексирования агрегата?