<pre>//====================== start of sample.cpp ========================== #include <stdio.h> #include <stdlib.h> #include <vector> class ServiceOrganization; class BuildingElement { static char* m_city; std::vector<int> m_flats; unsigned int m_square; ServiceOrganization& m_organization; FILE *m_document; BuildingElement* m_pNext; public: BuildingElement(); BuildingElement(BuildingElement&& src) : m_square(0) , m_organization(src.m_organization) , m_document(src.m_document) , m_pNext(src.m_pNext) { m_flats = src.m_flats; src.m_flats.clear(); src.m_organization = ServiceOrganization(); ::fclose(src.m_document); src.m_document = NULL; ::free(src.m_pNext); src.m_pNext = NULL; } };//====================== end of sample.cpp ========================== </pre> Какие операции, выполняемые в конструкторе переноса в файле sample.cpp являются лишними?
<pre> //====================== start of sample.cpp ========================== template<unsigned long N> class binary { public: static unsigned long const value = binary<N / 10>::value << 1 | N % 10; }; template<> class binary<0> { public: static unsigned long const value = 0; }; template<> class binary<1> { public: static unsigned long const value = 1; }; int main(int argc, char* argv[]) { static unsigned const x0 = binary<0>::value; static unsigned const x1 = binary<1000>::value; static unsigned const x2 = binary<1001>::value; static unsigned const x3 = binary<1010>::value; static unsigned const x4 = binary<1011>::value; return 0; } //====================== end of sample.cpp ========================== </pre> При инициализации какой переменной не будет использоваться конкретизация шаблона с параметром 0?
<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 ========================== template<unsigned long N> class binary { public: static unsigned long const value = binary<N / 10>::value << 1 | N % 10; }; template<> class binary<0> { public: static unsigned long const value = 0; }; int main(int argc, char* argv[]) { static unsigned const xyz = binary<111>::value; return 0; } //====================== end of sample.cpp ========================== </pre> Конкретизация шаблона с значением 111 приводит:
<pre> //====================== start of sample.cpp ========================== template<unsigned long N> class binary { public: static unsigned long const value = binary<N / 10>::value << 1 | N % 10; }; template<> class binary<0> { public: static unsigned long const value = 0; }; int main(int argc, char* argv[]) { if (argc > 1) { static unsigned const two = binary<10>::value; } return 0; } //====================== end of sample.cpp ========================== </pre> Когда будет посчитано значение переменной two?
<pre> //====================== start of sample.cpp ========================== #include <vector> template <class Storage, int size> class Input { public: Input() : m_store(size) {} private: Storage m_store; }; int main() { Input<int,5> a1; Input<int,6> a2; Input<std::vector<int>,10> v3; Input<std::vector<short>,10> v4; Input<double, 30> *pMyInput = nullptr; return 0; } //====================== end of sample.cpp ========================== </pre> Сколько описаний пользовательских типов будет в скомпилированном коде из файла sample.cpp?
<pre>//====================== start of sample.cpp ========================== #include <stdio.h> class Region; class Person { public: short m_age; const char* m_name; const char* m_surname; const char* m_region_name; Person(const char* name) : m_name(name) {} operator short () {return m_age;} operator const char* () {return "";} }; class Region { public: const char* region_name; const char* cheef_name; long size; Region(const char* region_nm = "") : region_name(region_nm) {} operator long () {return size;} operator const char* () {return region_name;} }; int main() { Person p1("Vasily Ivanov"); Region r; printf("Region number %u, driver %s", static_cast<unsigned short>(r), static_cast<const char*>(p1)); return 0; }//====================== end of sample.cpp ========================== </pre> Какие из имеющихся в файле sample.cpp конструкторов и операторов преобразования задействованы в операциях в функции main()?
<pre>//====================== start of sample.cpp ========================== class Person { public: short m_age; const char* m_name; const char* m_surname; }; class Library { public: long m_books_count; std::string m_name; static std::string m_city; }; class Program { public: std::string prog_name; long version; void* prog_data; }; class Region { public: short country_code; short city_code; std::shared_ptr<Library< main_library; };//====================== end of sample.cpp ========================== </pre> Для какого из классов в фрагменте файла sample.cpp необходима реализация своего оператора копирования?
<pre> //====================== start of sample.cpp ========================== class Program { public: static char* country; static const int version = 5; static short buid_num = 2223; static char* name; static long long date; }; Program prog; //====================== end of sample.cpp ========================== </pre> Какие объявления и обращения к членам класса и объекта prog, типа Program в файле sample.cpp корректны?
<pre> //====================== start of sample.cpp ========================== #include <climits> #include <limits> #include <boost/static_assert.hpp> namespace name { BOOST_STATIC_ASSERT(std::numeric_limits<int>::digits == 32); } int main(int argc, char* argv[]) { return 0; } //====================== end of sample.cpp ========================== </pre> Что случится c программой из файла sample.cpp если в системе размер int больше 32 разрядов?