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
overloading
:
Content language: Русский
English
Какой результат работы программы? #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); }
overloading
Можно ли сделать виртуальным перегруженный оператор?
overloading
Что напечатает следующий код? #include <iostream> using namespace std; struct A { A() { cout << "A()"; } A(int) { cout << "A(int)"; } void operator=(int) { cout << "="; } }; struct B { A a, b; B() : b(1) { a = 2; } }; int main() { B b; }
overloading
Скомпилируется ли следующий код: int foo(); char foo();
overloading
Что будет результатом следующей программы? #include <iostream> using namespace std; class A { public: A(); friend A &operator+(A &, const int); int getValue() const; private: int val; }; A::A() { val = 0; } int A::getValue() const { return val; } A &operator+ (A &sa, const int a) { sa.val += a; return sa; } int main(void) { A q, w; w + 3; // 1 q = q + 2; // 2 w = w + q.getValue(); // 3 cout << q.getValue() << w.getValue(); return 0; }
overloading
В зависимости от порядка создания объектов - аргументов переопределенного оператора, что будет выведено на экран в результате выполнения следующего кода? #include <memory> #include <iostream> class SomeObj { public: SomeObj() {} SomeObj(const int& val) : val_(std::make_shared<int>(val)) { std::cout << *val_; } void set(const int& val) { val_ = std::make_shared<int>(val); } friend bool operator&&(const SomeObj&, const SomeObj&); private: std::shared_ptr<int> val_; }; bool operator&&(const SomeObj& lhs, const SomeObj& rhs) { return lhs.val_ && rhs.val_; } int main() { if (SomeObj(1) && SomeObj(2)) { std::cout << 3; } return 0; }
overloading
Сколько методов по умолчанию в данном классе создаётся компилятором ? Class A { }
overloading
Что выведет такой код? #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; }
overloading
В результате создания объектов и вызова перегруженного оператора, какое значение будет выведено в консоль? #include <iostream> using namespace std; class Base { int* data; public: Base(int size, int value=0) { data = new int(value); } ~Base() { delete data; } Base &operator+=(Base src) { *data += *src.data; return *this; } operator int() { return *data; } }; int main() { Base a(2); Base b(2, 10); a += b; cout << b << endl; return 0; }
overloading
Как порядок вызова конструкторов и деструкторов повлияет на результат и что выведется на экран? #include <iostream> using namespace std; struct A { A() { cout << "A"; } ~A() { cout << "~A"; } virtual void operator()() = 0; }; struct B : A { B() { cout << "B"; } ~B() { cout << "~B"; } void operator()() { cout << "B"; } }; int main(void) { B b; A &a = b; a(); b(); return 0; }
overloading
← Prev
1
2
3
Next →
Sign Up Now
or
Subscribe for future quizzes