Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
inheritance
:
Content language: Русский
English
Что нужно изменить, чтобы данный код скомпилировался? class A{}; class B: A{}; void foo(A&a) {} int main(int argc, char* argv[]) { B b; foo(b); return 0; }
inheritance
Что выведет на экран данный код? #include <iostream> using namespace std; class A { public: int a=3; }; class B:public A { public: B(){str="Day";} ~B(){delete [] str;} char *str; }; int main(void) { A *lol=new A; cout<<lol->a; B* iop=(B *)lol; cout<<iop->str; return 0; }
inheritance
В каких из перечисленных строк произойдут ошибки компиляции: class Base { public: void method1(); protected: void method2(); private: void method3(); }; class Child : public Base { protected: void method1() { } void method2() { } void method3() { } }; int main() { Base* base = new Child(); base->method1(); // 1 base->method2(); // 2 base->method3(); // 3 return 0; }
inheritance
Что напечатает следующий код: #include "stdio.h" class Super1 { public: virtual void Count() { printf("%d", 1); } }; class Super2 { public: virtual void Count() { printf("%d", 2); } }; class Child : public Super1, public Super2 { public: void Count() { printf("%d", 3); } }; int main() { Super1 * obj = new Child; obj->Count(); return 0; }
inheritance
Что выведет следующий код: #include <iostream> using namespace std; class Base { public: void method(){}; }; class Child : public Base { public: void method() { cout << "Child"; }; }; int main() { Base* base = new Child(); base->method(); return 0; }
inheritance
Каким будет результат выполнения следующего кода: #include "stdio.h" class Parent { public: void Show(int iToShow) { printf("%d", iToShow); } }; class Child: public Parent { public: void Show() { printf("%d", 1); } }; int main() { Child obj; obj.Show(2); return 0; }
inheritance
Что будет выведено на экран? #include <iostream> class A { public: virtual void f() { std::cout << "A"; } }; class B : public A { private: void f() { std::cout << "B"; } }; void g(A& a) { a.f(); } int main () { B b; g(b); }
inheritance
Какой режим наследования использован ? class B { /*...*/ }; class A: B { /*...*/ };
inheritance
Что произойдет при компиляции и выполнении кода? #include <iostream> using namespace std; class A { public: A() { f("A()"); } ~A() { f("~A()"); } protected: virtual void f(const char* str) = 0; }; class B : public A { public: B() { f("B()"); } ~B() { f("~B()"); } protected: void f(const char* str) { cout<< str << endl; } }; int main() { B b; return 0; }
inheritance
Какие строчки нужно убрать, что бы код приведенный ниже компилировался : #include <iostream> class A{ public: virtual void foo() = 0; }; void A::foo() { std::cout << "A foo"; } class B : public A{}; class C : public A{ public: void foo(); }; void C::foo() { std::cout << "C foo"; } class D: public A{ public: void foo(); }; void D::foo() { A::foo(); } class E: public A{ public: //using A::foo; void foo(int) { std::cout << "E foo"; } }; int main(){ (new A)->foo(); // 1 (new B)->foo(); // 2 (new C)->foo(); // 3 (new D)->foo(); // 4 (new E)->foo(2); // 5 }
inheritance
← Prev
6
7
8
9
10
Next →
Sign Up Now
or
Subscribe for future quizzes