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

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

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

<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 обязательно должны быть инициализированы в списке инициализации?

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

Варианты ответа
m_city
m_square
m_organization(Верный ответ)
m_flats
m_high_size(Верный ответ)
Похожие вопросы
<pre>//====================== start of sample.cpp ========================== #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;vector&gt; class ServiceOrganization; class BuildingElement { static char* m_city; std::vector&lt;int&gt; m_flats; unsigned int m_square; ServiceOrganization& m_organization; FILE *m_document; BuildingElement* m_pNext; public: BuildingElement(); BuildingElement(BuildingElement&amp;&amp; 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&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?
<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 ========================== 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; template &lt;class Storage, int size&gt; class Input { public: Input() : m_store(size) {} private: Storage m_store; }; int main() { Input&lt;int,5&gt; a1; Input&lt;int,6&gt; a2; Input&lt;std::vector&lt;int&gt;,10&gt; v3; Input&lt;std::vector&lt;short&gt;,10&gt; v4; Input&lt;double, 30&gt; *pMyInput = nullptr; return 0; } //====================== end of sample.cpp ========================== </pre> Сколько описаний пользовательских типов будет в скомпилированном коде из файла sample.cpp?
<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: 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 необходима реализация своего оператора копирования?
<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;climits&gt; #include &lt;limits&gt; #include &lt;boost/static_assert.hpp&gt; namespace name { BOOST_STATIC_ASSERT(std::numeric_limits&lt;int&gt;::digits == 32); } int main(int argc, char* argv[]) { return 0; } //====================== end of sample.cpp ========================== </pre> Что случится c программой из файла sample.cpp если в системе размер int больше 32 разрядов?