C++
What is vi ...
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
What is virtual inheritance used for?
To pass virtual methods.
To create a single instance of a multiple class.
To pass a virtual destructor.
To pass protected virtual methods.
Explanation
Get an explanation when it's available:
Subscribe
virtual
inheritance
2
(2)
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Может ли чисто виртуальная функция иметь тело?
Что будет выведено? #include <iostream> using namespace std; class C { public: void Print() { cout << "CLASS C"; } }; class D : public C { public: void Print() { cout << "CLASS D"; } }; int main() { C *test = new D(); test->Print(); }
Что выведется на экран ? #include <iostream> using namespace std; class A { public: virtual void Foo(int n = 10) { cout << "A::Foo, n = " << n << endl; } }; class B : public A{ public: virtual void Foo(int n = 20) { cout << "B::Foo, n = " << n << endl; } }; int main() { A * pa = new B(); pa->Foo(); return 0; }
Что будет выведено на экран? class A1 { public: virtual void k(){std::cout<<"A1";} }; class B1: public A1 { public: void k(){std::cout<<"B1";} }; void function(A1 a) { a.k(); } int main() { B1 b; function(b); }
Что выведет на экран следующая программа? #include <iostream> using namespace std; struct A { void foo() { cout << "A::foo()\n"; } }; struct B : virtual A { virtual void foo() { cout << "B::foo()\n"; } }; struct C : B, virtual A { void foo() { cout << "C::foo()\n"; } }; int main (int argc, char *argv[]) { C().foo(); A *a = new C; a->foo(); static_cast<A*>(new C)->foo(); return 0; }
Что выведет такой код? #include <iostream> struct A { virtual void method() const { std::cout << "A" << std::endl; } virtual ~A(){} }; struct B : A { virtual void method() { std::cout << "B" << std::endl; } }; int main() { A * ptr = new B(); ptr->method(); delete ptr; return 0; }
C
++
Quiz
Login to learn C++
or
Read more about
C++ Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
C++ quizzes
int main() { const int* i = int(); // 1 int const* j = int(); //2 int* const k = int(); //3 int* l(); //4 ++i; //5 ++j; //6 ++k; //7 ++*k; //8 ++l; //9 } Откомпилируется ли такой код? Если нет, то в каких строчках будут ошибки компиляции? После стандарта C++14.
Какой результат работы программы? #include <iostream> using namespace std; void f(double) { cout<<"f1"<<endl; } void f(const int ) { cout<<"f2"<<endl; } void f( int & ) { cout<<"f3"<<endl; } void main(void) { int n = 1; double b = 2; f(n); f(b); }
#include <iostream> using namespace std; int &test() { static int a = 3; return a; } int main() { ++++++test(); cout << test() << endl; return 0; } Что выведет cout?
При истинности какого из приведенных высказываний имеет смысл вычитание указателей?
Какое ключевое слово используется для описания пространства имен?
В чем разница между X x; и X x(); ?
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment