<pre> //====================== start of sample3.h ========================== #include <list> #include <vector> template<class Storage> class MyIter {}; template<class Storage> void my_input_process(Storage* in_item) {} template<class Storage, int size> void clear_all(Storage*); template <class Storage, class Element, int size> class BackupInput {}; template <class Storage, class Element, int size> class Input { public: Input() : m_store(size) {} friend class MyIter<Storage>; friend void my_input_process<Storage>(Storage*); friend void clear_all<Storage, 100>(Storage*); friend class BackupInput<Storage, Element, size>; private: Storage m_store; }; Input<std::list<short>, short, 25> input25; int main() { MyIter<std::list<short>> my_iter; BackupInput<std::list<short>, short, 25> backup_input; my_input_process<std::vector<short>>(nullptr); clear_all<std::vector<short>, 25>(nullptr); clear_all<std::list<short>, 100>(nullptr); return 0; } //====================== end of sample3.h ========================== </pre> Какие функции и классы в файле sample.cpp имеют доступ к всем атрибутам глобального объекта input25?
<pre>//====================== start of sample.cpp ========================== class Input { public: Input(); ~Input(); virtual void f(); }; class ManualUserDev: public Input { public: ManualUserDev(); virtual ~ManualUserDev(); }; class Keyboard: public Input { public: Keyboard(); ~Keyboard(); }; int main() { Keyboard keyboard; Input& rinp = keyboard; Input* pinp = &:keyboard; ManualUserDev& rmy_mdev = dynamic_cast<ManualUserDev&>(rinp); ManualUserDev* pmy_mdev = dynamic_cast<ManualUserDev*>(pinp); Keyboard& rmy_keyboard = dynamic_cast<Keyboard&>(rinp); Keyboard* pmy_keyboard = dynamic_cast<Keyboard*>(pinp); return 0; }//====================== end of sample.cpp ========================== </pre> При инициализации какой переменной в файле sample.cpp будет брошено исключение?
<pre>//====================== start of sample.cpp ========================== class Input { public: Input(); ~Input(); }; class USBDev { public: ~USBDev(); }; class USBInput: public Input { USBDev m_dev; public: USBInput(): Input() {} ~USBInput(); }; class Device { public: Device(); ~Device(); }; class ManualUserDev: public Device { public: ManualUserDev() : Device() {} ~ManualUserDev(); }; class Key { public: ~Key(); }; class Keyboard: public USBInput, public ManualUserDev { Key* key; public: Keyboard(): ManualUserDev(), Input() {key = new Key();} ~Keyboard() { delete key; } };//====================== end of sample.cpp ========================== </pre> В каком порядке вызываются деструкторы при удалении объекта Keyboard из файла sample.cpp?
<pre>//====================== start of sample.cpp ========================== class Input { public: Input(); ~Input(); }; class USBInput: public Input { public: USBInput(); virtual ~USBInput(); }; class Device { public: Device(); ~Device(); }; class USBDevice: virtual public Device { public: USBDevice(); virtual ~USBDevice(); }; class ManualUserDev: public virtual USBInput { public: ManualUserDev(); virtual ~ManualUserDev(); }; class Key { public: Key(); ~Key(); }; class Keyboard: public Input, public Key { public: Keyboard(); ~Keyboard(); };//====================== end of sample.cpp ========================== </pre> Для которых из классов в файле sample.cpp в конструкторе может потребоваться явно вызвать конструкторы базовых классов?
<pre>//====================== start of sample.cpp ========================== class Input { public: Input(); }; class USBInput: public Input { public: USBInput(): Input() {} }; class Device { public: Device(); }; class ManualUserDev: public Device { public: ManualUserDev() : Device() {} }; class Keyboard: public USBInput, public ManualUserDev { public: Keyboard(): ManualUserDev(), USBInput() {} };//====================== end of sample.cpp ========================== </pre> Тело конструктора какого класса будет исполнено последним перед вызовом тела конструктора Keyboard при создании класса типа Keyboard?
<pre>//====================== start of sample.cpp ========================== class Input { public: Input(); }; class Output { public: Output(); }; class USBInput { }; class USBOutput { }; class SimpleComputer { long m_memory; const char* m_processor; Input m_input; Output m_output; public: long GetPerformance(); void Start(); void Reset(); }; class PersonalComputer: public SimpleComputer { USBInput m_input; UserOutput m_output; }; class LaptopComputer: public PersonalComputer { const char* m_processor; public: void Start(); void Reset(); };//====================== end of sample.cpp ========================== </pre> Какие атрибуты и методы базового класса SimpleComputer в файле sample.cpp остались не перекрыты в унаследованном классе LaptopComputer?
<pre> //====================== start of sample.cpp ========================== template <class Element, unsigned long max_size> class Storage { public: Storage(Element) {} }; template <class Element> class Storage <Element, 0 /* unlimited*/> { public: Storage(Element e) {} }; template <unsigned long max_size> class Storage <int, max_size> { public: Storage(int e) {} }; template <> class Storage<char*, 0> { public: Storage(char* s) {} }; template <> class Storage<char*, 100> { public: Storage(char* s) {} }; int main() { int p1=4; Storage<int, 5> st1(p1); Storage<char*, 100> st2(char* s); Storage<double, 80000> st3(double n); Storage<double, 0> st4(double n); return 0; } //====================== end of sample.cpp ========================== </pre> Какой из шаблонов Storage в файле sample.cpp не задействован в функции main в файле sample.cpp?
<pre>//====================== start of sample.cpp ========================== #include <vector> class ServiceOrganization; class Building { static char* m_city; const unsigned int m_high_size; std::vector<int> m_flats; unsigned int m_square; ServiceOrganization& m_organization; public: Building(); }; int main() { Building house; return 0; }//====================== end of sample.cpp ========================== </pre> Какие члены класса Building из файла sample.cpp обязательно должны быть инициализированы в списке инициализации?
<pre>//====================== start of sample.cpp ========================== #include <vector> class Person { public: short m_age; const char* m_name; const char* m_surname; const char* m_region_name; }; class Region { public: const char* region_name; const char* cheef_name; long size; }; int main() { std::vector<unsigned char>* mybuffer = new std::vector<unsigned char>(sizeof(Person) + sizeof(Region), 0); Person* my_person = new (&(mybuffer->at(0))) Person(); my_person->~Person(); delete my_person; Region* p_region = new (&(mybuffer->at(0))) Region(); p_region->~Region(); delete p_region; delete mybuffer; return 0; }//====================== end of sample.cpp ========================== </pre> Какие операции освобождений ресурсов в файле sample.cpp являются лишними или ошибочными?
<pre> //====================== start of sample.cpp ========================== #include <type_traits> template <typename IT_1, typename IT_2, bool b> IT_2 copy_imp(IT_1 first, IT_1 last, IT_2 out, const std::integral_constant<bool, b>&) { while(first != last) { *out = *first; ++out; ++first; } return out; } template <typename T> T* copy_imp(const T* first, const T* last, T* out, const std::true_type&) { memmove(out, first, (last-first)*sizeof(T)); return out * (last-first); } template <typename I1, typename I2> inline I2 copy(I1 first, I1 last, I2 out) { typedef typename std::iterator_traits<I1>::value_type value_type; return copy_imp(first, last, out, std::has_trivial_assign<value_type>()); } class A {}; int main() { std::vector<short> arr1; std::vector<short> arr2; copy(arr1.begin(), arr1.end(), arr2.begin()); return 0; } //====================== end of sample.cpp ========================== </pre> Какие утверждения про используемую функцию копирования copy_impl() верны?