<pre> //====================== start of sample.cpp ========================== class Program { static char* prog_name; volatile long threads_count; mutable double time_of_work; long version; public: static char* get_name() { return prog_name; } long* getthreadscount() { return &threads_count; } volatile long* get_threads_count() { return &threads_count; } static double get_time_of_work() { return time_of_work; } volatile long get_version() { return version; } }; //====================== end of sample.cpp ========================== </pre> Какие методы в файле sample.cpp корректно обращаются к членам класса?
<pre> //====================== start of sample.cpp ========================== class Program { char* prog_name; public: long threads_count; double time_of_work; long version; }; const Program& get_my_program(); int main() { Program& prg = const_cast<Program&>(get_my_program()); long Program::*pmy_thr_count = &Program::threads_count; long my_threads_1 = *pmy_thr_count; long my_threads_2 = prg.*pmy_thr_count; long Program::*pversion = &Program::version; long my_version = (&prg)->*pversion; char* Program::*pmy_name = &Program::prog_name; char* my_name = prg.*pmy_name; return 0; } //====================== end of sample.cpp ========================== </pre> Какие присвоения значений членов класса переменным будут успешны в файле sample.cpp?
<pre> //====================== start of sample.cpp ========================== class Program { long threads_count; double time_of_work; public: char* prog_name; long version; long get_threads_count(); double get_time_of_work(); }; const Program& get_my_program(); typedef double (Program::*my_getter)(); int main() { long Program::*pversion = &Program::version; char* Program::*pmy_name = &Program::prog_name; long (Program::*f_threads_count)() = &Program::get_threads_count; Program& prg = const_cast<Program&>(get_my_program()); long my_version = (prg)->*pversion; char* my_name = prg.*pmy_name; long my_threads_count = (prg.f_threads_count)(); my_getter getter = &Program::get_time_of_work; double my_time_of_work = (prg.*getter)(); return 0; } //====================== end of sample.cpp ========================== </pre> Какие присвоения значений членов класса переменным будут успешны в файле sample.cpp?
<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 ========================== 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 <iostream> class Program; class ProgDataGetter { public: const char* prog_name(const Program& prg); long get_version(const Program& prg); }; class Program { long threads_count; double time_of_work; class Module { char* module_name; }; char* prog_name; long version; Module modules[16]; friend std::iostream& operator >> (std::iostream& io, Program& prg); friend std::iostream& operator << (std::iostream& io, const Program& prg); friend class VersionGetter; friend const char* ProgDataGetter::prog_name(const Program&); }; std::iostream& operator >> (std::iostream& io, Program& prg) { io >> prg.prog_name >> prg.threads_count; } std::iostream& operator << (std::iostream& io, const Program& prg) { io << prg.prog_name << prg.modules[0].module_name << prg.modules[1].module_name; } class VersionGetter { public: long get_version(Program& prg) { return prg.version; } }; const char* ProgDataGetter::prog_name(const Program& prg) { return prg.prog_name; } long ProgDataGetter::get_version(const Program& prg) { return prg.version;} //====================== end of sample.cpp ========================== </pre> Для каких функций и методов корректно организован доступ к членам класса Program файле 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 ========================== 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 User { public: const char* name; inline int age; private: volatile double balance; mutable char* job_name; protected: long long phone_number; static int phone_prefix = 499; }; //====================== end of sample.cpp ========================== </pre> Какие атрибуты класса 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; }; int main(int argc, char* argv[]) { if (argc > 1) { static unsigned const two = binary<10>::value; } return 0; } //====================== end of sample.cpp ========================== </pre> Когда будет посчитано значение переменной two?