<pre> //====================== start of sample.cpp ========================== template <typename T> class multiplies: public binary_function<T,T,T> { public: T operator() (const T& x, const T& y) const { return x * y; } }; //====================== end of sample.cpp ========================== </pre> Какие утверждения про приведённый выше код функтора multiplies верны?
<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 ========================== #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 User { public: struct Region { short country_code; short city_code; static char* city_name; }; const char* name; int age; double balance; Region region; const char* get_name() const { return (*this).name; } int get_age() const { return this->age; } double get_balance() const { return (*this)->balance; } short get_country_code() const { return Region::country_code; } short get_city_code() const { return region.city_code; } const char* get_city_name() const { return Region::city_name; } }; //====================== end of sample.cpp ========================== </pre> В каких методах обращения к членам объекта класса user типа User корректны?
<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 ========================== int main(int argc, char* argv[]) { const int a = 0; int b = 0; const int X = 0; int Y = 0; int Z = 0; auto lf1 = [&Y, Z, &a, &b, X] (double x) {return x > 0;}; return 0; } //====================== end of sample.cpp ========================== </pre> Значения каких переменным лямбда функция lf1 может изменить?
<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 ========================== 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 ========================== #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 ========================== class Program { const char* prog_name; long threads_count; mutable double time_of_work; public: const char* get_name() const { return prog_name; } long get_threads_count() { return threads_count; } bool set_time_of_work(double in_time) const { time_of_work = in_time; return true; } bool add_time_of_work(double in_time) { time_of_work += in_time; return true; } }; const Program& get_my_program(); int main() { const Program& prg = get_my_program(); const char* prg_name1 = prg.get_name(); long my_thr_count1 = prg.get_threads_count(); bool result1 = prg.add_time_of_work(1); Program& prg2 = const_cast<Program& >(prg); long my_thr_count2 = prg2.get_threads_count(); bool result2 = prg2.set_time_of_work(0); bool result3 = prg2.add_time_of_work(1); return 0; } //====================== end of sample.cpp ========================== </pre> При присвоении значений каким переменным в файле sample.cpp корректно используются корректно определённые методы?