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
pointers
:
Content language: Русский
English
Что будет выведено в stdout при выполнении следующего кода? #include <iostream> struct A { A() { std::cout << "A"; } ~A() { std::cout << "~A"; } }; int main() { A *a = (A *) operator new(sizeof *a); delete a; }
pointers
При выполнении/компиляции каких строк произойдут ошибки? char *s1((char *)("foo")); //1 char s2[] = "foo"; //2 char *s3 = (char *) new char[10]; //3 s1[2] = 'a'; //4 *s2 = 'b'; //5 3[s3] = 'c'; //6
pointers
Что будет выведено в stdout при выполнении этого кода? #include <iostream> using std::cout; int* treble(int); int main(void) { int num = 5; int* ptr = 0; ptr = treble(num); cout << *ptr; return 0; } int* treble(int data) { int a = 0; if (data >= 5) { int b = 3 * data; return &b; } return &a; }
pointers
Каким будет результат выполнения следующего кода: #include "iostream" class A { public: virtual int mathFunc(int n = 1) {return n+n;} }; class B: public A { public: int mathFunc(int n = 2) {return n*n;} }; int main() { A a, *pa; B b; pa = &b; std::cout << a.mathFunc(3) << pa->mathFunc(-1) << pa->mathFunc() << b.mathFunc(); }
pointers
Что не верно в следующем коде: class Parent { public: ~Parent() { } virtual void method() { } }; class Child : public Parent { public: Child() { /* захват ресурсов */ } ~Child() { /* освобождение ресурсов */ } void method() { /* программный код */ } }; int main() { Parent * obj = new Child; // программный код delete obj; return 0; }
pointers
Каков результат компиляции и выполнения следующего кода: #include <iostream> using namespace std; class Shape { virtual void show() = 0; }; class Circle: public Shape { void show() { std::cout<<"Circle\n"; } }; class Triangle: Shape { void show() { std::cout<<"Triangle\n"; } }; int main(int argc, char* argv[]) { Shape* shape1; shape1 = new Circle(); shape1->show(); Shape* shape2 = new Triangle(); shape2->show(); delete shape1; delete shape2; return 0; }
pointers
Какое исключение возбуждается, если в качестве аргумента передать оператору typeid нулевой указатель?
pointers
Что выведет программа? #include "iostream" using namespace std; class A { public: A() {constr();} virtual ~A() {destr();} virtual void constr() const {;} virtual void destr() const {;} }; class B: virtual public A { public: B() {constr();} ~B() {destr();} void constr() const {cout << "B" ;} void destr() const {cout << "~B";} }; int main() { A *a, *b; a = new A; b = new B; delete b; delete a; }
pointers
Какой будет результат выполнения программы? #include <stdio.h> class Grand { public: virtual void Count() = 0; }; class ParentFather : virtual public Grand{ public: virtual void Count() { printf("%d", 1); } virtual void Count(int i) { printf("%d", i + 1); } }; class ParentMother : virtual public Grand{ public: virtual void Count() { printf("%d", 2); } virtual void Count(int i) { printf("%d", i + 2); } }; class Child : public ParentFather, public ParentMother { void Count() { printf("%d", 3); } void Count(int i) { printf("%d", i + 3); } }; int main() { ParentFather *grand = new Child; ParentMother *mother = dynamic_cast<ParentMother*>(grand); mother->Count(25.9); return 0; }
pointers
Что выведет программа: #include <iostream> struct B { void PrintIt() { std::cout << "Does it work?" << std::endl; } }; int main() { B *obj = NULL; obj->PrintIt(); return 0; }
pointers
← Prev
6
7
8
9
10
Next →
Sign Up Now
or
Subscribe for future quizzes