C++
Select the ...
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
Select the correct statements. The unary operation for a class can be overloaded as:
Non-static member function with no arguments
A global function with one argument (the argument is a class object or a reference to it)
Static member function with no arguments
Global function without arguments
A non-static member function with one argument (argument is a class object or a reference to it)
Explanation
Get an explanation when it's available:
Subscribe
class
operators
overloading
unary
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Что будет результатом следующей программы? #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; }
Можно ли сделать виртуальным перегруженный оператор?
Что напечатает следующий код? #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; }
В зависимости от порядка создания объектов - аргументов переопределенного оператора, что будет выведено на экран в результате выполнения следующего кода? #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; }
Сколько методов по умолчанию в данном классе создаётся компилятором ? Class A { }
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