C++
What happe ...
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 happens if the standard
new
operator cannot allocate memory for an object?
The standard
new
operator should always allocate memory for the requested object, so it will return a pointer to the allocated memory for the object.
0 will be returned
An exception will be thrown
Explanation
Get an explanation when it's available:
Subscribe
operator new
exceptions
memory
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Какой вывод будет у этой программы? #include <iostream> #include <string.h> using namespace std; const char a[] = "12345"; int main() { char* b = new char[sizeof(a)]; strncpy(b, a, sizeof(a)); char* c = new(b) char('5'); cout << a << endl << b << endl << c; }
Корректен ли такой код в плане освобождения ресурсов? #include <exception> struct A { ~A() { throw std::exception(); } };
Что будет выведено в stdout при выполнении следующего кода? #include <iostream> struct A { A() { std::cout << "A"; } ~A() { std::cout << "~A"; } }; int main() { A *a = (A *) operator new(sizeof *a); delete a; }
#include <iostream> using namespace std; int &test() { static int a = 3; return a; } int main() { ++++++test(); cout << test() << endl; return 0; } Что выведет cout?
Что означает конструкция throw() в объявлении функции? (например void f() throw();)
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); }
При истинности какого из приведенных высказываний имеет смысл вычитание указателей?
Какое ключевое слово используется для описания пространства имен?
В чем разница между X x; и X x(); ?
Скомпилируется ли этот код: struct A : int { };
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment