<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& in_b); //====================== end of sample.h ========================== </pre> Какие присвоения и объявления в файле sample.h валидны?
<pre> //====================== start of sample.cpp ========================== struct A { A(); virtual ~A(); private: A(A&a); A& operator=(const A& a); }; struct B: public A {}; struct C {}; struct D { D(); D& operator=(const D& 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& a) {} catch(static const B*) {} catch(C c) {} catch(volatile D* d) {} catch(virtual E* e) {} catch(F*&) {} catch(...) { return 5; } return 0; } //====================== end of sample.cpp ========================== </pre> Обработчики исключений какого типа записаны неправильно?
<pre> //====================== start of sample.cpp ========================== #include <boost/variant/variant.hpp> struct A {}; struct B { B(int src); private: B(const B& src); }; struct C { C(int src); private: C(); }; struct D {}; int main(int argc, char* argv[]) { boost::variant<int, A, B, C> 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.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&) { } catch(B&) { throw D(); } catch(D&) { throw C(); } catch(...) { throw; } int main(int argc, char* argv[]) { try { foo(argc); } catch(const A& 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 <typename T> struct remove_extend { typedef T type; }; template <typename T, std::size_t N> struct remove_extend<T[N]> { typedef T type; }; //====================== end of sample.cpp ========================== </pre> Что произойдёт если не определять специализированный шаблон remove_extend<T[N]> для массива??
<pre> //====================== start of sample.cpp ========================== #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> #include <vector> struct A { virtual ~A(); }; struct B: public A {}; struct C {}; void foo1(boost::shared_ptr<A>& a); void foo2(boost::shared_ptr<A const> a); void foo3(boost::shared_ptr<B>& a); void foo4(boost::shared_ptr<const A> a, boost::shared_ptr<C> c); void foo5(std::vector< boost::shared_ptr<C> >& c); int main(int argc, char* argv[]) { boost::shared_ptr<A> b1(new A); boost::shared_ptr<B> b2(new B); boost::shared_ptr<C> b3(new C); boost::weak_ptr<A> b4(b1); std::vector<boost::shared_ptr<C>> v1; v1.push_back(b3); foo1(b1); foo2(b2); foo3(b3); foo4(b4.lock(), b3); foo5(v1); return 0; } //====================== end of sample.cpp ========================== </pre> Вызовы каких функций выполнены корректно и операции создания их параметров не содержат очевидных проблем?