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

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

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

<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 валидны?

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

Варианты ответа
a(Верный ответ)
b
void foo()(Верный ответ)
pb(Верный ответ)
pa(Верный ответ)
Похожие вопросы
<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.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?
<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 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.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 {}; 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 ========================== #include &lt;boost/shared_ptr.hpp&gt; #include &lt;boost/weak_ptr.hpp&gt; #include &lt;vector&gt; struct A { virtual ~A(); }; struct B: public A {}; struct C {}; void foo1(boost::shared_ptr&lt;A&gt;&amp; a); void foo2(boost::shared_ptr&lt;A const&gt; a); void foo3(boost::shared_ptr&lt;B&gt;&amp; a); void foo4(boost::shared_ptr&lt;const A&gt; a, boost::shared_ptr&lt;C&gt; c); void foo5(std::vector&lt; boost::shared_ptr&lt;C&gt; &gt;&amp; c); int main(int argc, char* argv[]) { boost::shared_ptr&lt;A&gt; b1(new A); boost::shared_ptr&lt;B&gt; b2(new B); boost::shared_ptr&lt;C&gt; b3(new C); boost::weak_ptr&lt;A&gt; b4(b1); std::vector&lt;boost::shared_ptr&lt;C&gt;&gt; v1; v1.push_back(b3); foo1(b1); foo2(b2); foo3(b3); foo4(b4.lock(), b3); foo5(v1); return 0; } //====================== end of sample.cpp ========================== </pre> Вызовы каких функций выполнены корректно и операции создания их параметров не содержат очевидных проблем?
<pre> //====================== start of sample.cpp ========================== template &lt;typename T&gt; struct remove_extend { typedef T type; }; template &lt;typename T, std::size_t N&gt; struct remove_extend&lt;T[N]&gt; { typedef T type; }; //====================== end of sample.cpp ========================== </pre> Что произойдёт если не определять специализированный шаблон remove_extend<T[N]> для массива??