База ответов ИНТУИТ

Программирование на С/С++

<<- Назад к вопросам

<pre> //====================== start of sample.cpp ========================== template&lt;unsigned long N&gt; class binary { public: static unsigned long const value = binary&lt;N / 10&gt;::value &lt;&lt; 1 | N % 10; }; template&lt;&gt; class binary&lt;0&gt; { public: static unsigned long const value = 0; }; template&lt;&gt; class binary&lt;1&gt; { public: static unsigned long const value = 1; }; int main(int argc, char* argv[]) { static unsigned const x0 = binary&lt;0&gt;::value; static unsigned const x1 = binary&lt;1000&gt;::value; static unsigned const x2 = binary&lt;1001&gt;::value; static unsigned const x3 = binary&lt;1010&gt;::value; static unsigned const x4 = binary&lt;1011&gt;::value; return 0; } //====================== end of sample.cpp ========================== </pre> При инициализации какой переменной не будет использоваться конкретизация шаблона с параметром 0?

(Ответ считается верным, если отмечены все правильные варианты ответов.)

Варианты ответа
x1(Верный ответ)
x4(Верный ответ)
x0
x2(Верный ответ)
x3(Верный ответ)
Похожие вопросы
<pre> //====================== start of sample.cpp ========================== template&lt;unsigned long N&gt; class binary { public: static unsigned long const value = binary&lt;N / 10&gt;::value &lt;&lt; 1 | N % 10; }; template&lt;&gt; class binary&lt;0&gt; { public: static unsigned long const value = 0; }; int main(int argc, char* argv[]) { static unsigned const xyz = binary&lt;111&gt;::value; return 0; } //====================== end of sample.cpp ========================== </pre> Конкретизация шаблона с значением 111 приводит:
<pre> //====================== start of sample.cpp ========================== template&lt;unsigned long N&gt; class binary { public: static unsigned long const value = binary&lt;N / 10&gt;::value &lt;&lt; 1 | N % 10; }; template&lt;&gt; class binary&lt;0&gt; { public: static unsigned long const value = 0; }; int main(int argc, char* argv[]) { if (argc &gt; 1) { static unsigned const two = binary&lt;10&gt;::value; } return 0; } //====================== end of sample.cpp ========================== </pre> Когда будет посчитано значение переменной two?
<pre>//====================== start of sample.cpp ========================== #include &lt;vector&gt; class ServiceOrganization; class Building { static char* m_city; const unsigned int m_high_size; std::vector&lt;int&gt; m_flats; unsigned int m_square; ServiceOrganization&amp; m_organization; public: Building(); }; int main() { Building house; return 0; }//====================== end of sample.cpp ========================== </pre> Какие члены класса Building из файла 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 &lt;vector&gt; 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&lt;unsigned char&gt;* mybuffer = new std::vector&lt;unsigned char&gt;(sizeof(Person) + sizeof(Region), 0); Person* my_person = new (&amp;(mybuffer->at(0))) Person(); my_person-&gt;~Person(); delete my_person; Region* p_region = new (&amp;(mybuffer-&gt;at(0))) Region(); p_region-&gt;~Region(); delete p_region; delete mybuffer; return 0; }//====================== end of sample.cpp ========================== </pre> Какие операции освобождений ресурсов в файле 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 ========================== #include &lt;stdio.h&gt; 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 &quot;&quot;;} }; class Region { public: const char* region_name; const char* cheef_name; long size; Region(const char* region_nm = &quot;&quot;) : region_name(region_nm) {} operator long () {return size;} operator const char* () {return region_name;} }; int main() { Person p1(&quot;Vasily Ivanov&quot;); Region r; printf(&quot;Region number %u, driver %s&quot;, static_cast&lt;unsigned short&gt;(r), static_cast&lt;const char*&gt;(p1)); return 0; }//====================== end of sample.cpp ========================== </pre> Какие из имеющихся в файле sample.cpp конструкторов и операторов преобразования задействованы в операциях в функции main()?
<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 наследование выполнено для наследования интерфейса?
Какие присвоения для const int ct; const unsigned int* pt; long const* cpt; допустимы?
<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&lt;Library&lt; main_library; };//====================== end of sample.cpp ========================== </pre> Для какого из классов в фрагменте файла sample.cpp необходима реализация своего оператора копирования?