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

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

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

<pre> //====================== start of sample.cpp ========================== template &lt;class Receiver&gt; class MyCommand: public Command { public: typedef void (Receiver::* Action)(); MyCommand(Receiver r, Action a): _receiver(r), _action(a){} void Execute(); int GetStatus(); private: Action _action; Receiver* _receiver; int _last_error; }; //====================== end of sample.cpp ========================== </pre> Какие атрибуты и методы класса MyCommand являются необходимыми для имплементации шаблона команда в файле sample.cpp?

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

Варианты ответа
_last_error;
_receiver;(Верный ответ)
GetStatus();
Execute();(Верный ответ)
_action;(Верный ответ)
Похожие вопросы
<pre>//====================== start of sample.cpp ========================== class Input { public: Input(); }; class Output { public: Output(); }; class USBInput { }; class USBOutput { }; class SimpleComputer { long m_memory; const char* m_processor; Input m_input; Output m_output; public: long GetPerformance(); void Start(); void Reset(); }; class PersonalComputer: public SimpleComputer { USBInput m_input; UserOutput m_output; }; class LaptopComputer: public PersonalComputer { const char* m_processor; public: void Start(); void Reset(); };//====================== end of sample.cpp ========================== </pre> Какие атрибуты и методы базового класса SimpleComputer в файле sample.cpp остались не перекрыты в унаследованном классе LaptopComputer?
<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 ========================== class ARef { public: ARef(A &amp;a, int i) : _a(a), _ix(i) {} ARef&amp; operator= (T t) { return *this;} operator T() {return _t;} operator A() {return _a;} A& getA() { return _a;} bool operator == (A&amp; a) {return _a == a;} private: A&amp; _a; int _ix; T _t; }; class A { friend class ARef; public: A() {} ARef operator[] (int ix) {return ARef(*this, ix);} operator ARef() {return ARef(*this, ix);} }; //====================== end of sample.cpp ========================== </pre> Какие из методов класса ARef из файла sample.cpp являются необходимыми для поддержки идиомы контекстно-зависимой перегрузки операции индексирования агрегата?
<pre> //====================== start of sample.h ========================== struct S_EMPTY {}; struct A { int i; double g; }; class B { long jj; public: char _str[6]; private: static char str_4_all[9]; }; union mytypes_t { int i; float f; } My; //====================== end of sample.h ========================== </pre> Доступ к каким из членов класса, описанных в файле sample.h (выше), является открытым?
<pre> //====================== start of sample.h ========================== struct S_EMPTY {}; struct A { int i; double g; }; class B { long jj; public: char _str[6]; private: static char str_4_all[9]; }; union mytypes_t { int i; float f; } My; //====================== end of sample.h ========================== </pre> Доступ к каким из членов класса, описанных в файле sample.h (выше), является закрытым?
<pre> //====================== start of sample.hpp ========================== class ARef { public: /* Сonstructory */ ARef(A&amp; a, int i) : _a(a), _ix(i) {} /* operator= */ ARef&amp; operator= (T t) { return *this;} private: A&amp; _a; // Reference to A object int _ix; // index in container }; class BRef { public: BRef(B &amp;b, int i) : _b(b), _ix(i) {} BRef&amp; operator= (T t) { return *this;} private: B&amp; _b; int _ix; }; /* * Class CRef имплементирует шаблон проектирования X * хранит в себе ссылку на коллекцию типа A, которая является коллекцией * объектов типа T и предоставляет к ним доступ */ class CRef { public: CRef(C &amp;c, int i) : _c(c), _ix(i) {} CRef&amp; operator= (T t) { return *this;} private: C&amp; _c; /* та коллекция объектов, доступ к которой и предоставляется*/ int _ix; /* индекс текущего объекта в контейнере */ }; /* * Class DRef */ class DRef { public: // конструктор инициализирует объект DRef(D &amp;d, int i) : m_d(d), _ix(i) {} // оператор возвращает ссылку на себя DRef&amp; operator= (T t) { return *this;} private: D&amp; m_d; // хранимый объект int _ix; // индекс }; //====================== end of sample.hpp ========================== </pre> Комментарии какого из классов в файле sample.hpp являются необходимыми и достаточными?
<pre> //====================== start of sample.cpp ========================== template &lt;class Element, unsigned long max_size&gt; class Storage { public: Storage(Element) {} }; template &lt;class Element&gt; class Storage &lt;Element, 0 /* unlimited*/&gt; { public: Storage(Element e) {} }; template &lt;unsigned long max_size&gt; class Storage &lt;int, max_size&gt; { public: Storage(int e) {} }; template &lt;&gt; class Storage&lt;char*, 0&gt; { public: Storage(char* s) {} }; template &lt;&gt; class Storage&lt;char*, 100&gt; { public: Storage(char* s) {} }; int main() { int p1=4; Storage&lt;int, 5&gt; st1(p1); Storage&lt;char*, 100&gt; st2(char* s); Storage&lt;double, 80000&gt; st3(double n); Storage&lt;double, 0&gt; st4(double n); return 0; } //====================== end of sample.cpp ========================== </pre> Какой из шаблонов Storage в файле sample.cpp не задействован в функции main в файле 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&lt;Library&lt; main_library; };//====================== end of sample.cpp ========================== </pre> Для какого из классов в фрагменте файла sample.cpp необходима реализация своего оператора копирования?
<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&lt;typename T&gt; typename T::difference_type my_diff( T&amp; v1, T&amp; v2); template&lt;typename T&gt; T my_diff2(T&amp; v1, T&amp; v2); class A { public: A(int in = 5); typedef short difference_type; difference_type operator-(A&amp;); }; int main() { A i(5); A j(10); my_diff(i,j); int x = 5; int y = 10; my_diff(x,y); return 0; } //====================== end of sample.cpp ========================== </pre> Какие проблемы может решить использование идиомы SFINAE в вышеприведённом коде?