<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 ========================== 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 <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 ========================== class Person { public: long GetAge(); bool IsMale(); }; class Trader: private Person { public: long GetAge(); long GetAccount(); }; class Worker { public: long GetExperience(); long GetSalary(); }; class Developer : public Worker, private Person { }; class Boss: protected Worker { public: unsigned short GetLevel(); const char* GetDepartment(); }; class HeadOfAll: public Boss {};//====================== 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 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 <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 <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 ========================== class User { public: const char* get_name() const; inline int get_age const; private: volatile double get_balance(); mutable char* get_job_name(); protected: long long get_phone_number(); static int get_phone_prefix(); }; //====================== end of sample.cpp ========================== </pre> Какие методы класса User объявлены корректно?
<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 необходима реализация своего оператора копирования?