C++
What excep ...
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 exception throws
dynamic_cast
if it is not possible to convert the type of the class reference?
std::bad_cast
std::bad_exception
std::invalid_argument
std::bad_weak_ptr
Explanation
Get an explanation when it's available:
Subscribe
data-type-conversion
references
exceptions
dynamic_cast
class
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Какой результат выполнения следующей программы? #include <iostream> using namespace std; class A { public: A() {} ~A() {} void f(){cout<<"A::f();"<<endl;} }; class B: virtual public A { public: B() {} ~B() {} void f(){cout<<"B::f();"<<endl;} }; int main(){ A * a = new B(); B * b = dynamic_cast<B *>(a); b->f(); delete a; }
Что произойдёт в результате попытки преобразования dynamic_cast: #include <iostream> using namespace std; class A{ public: virtual ~A() {} }; class B: public A{ }; int main(){ A * a = new A(); try{ B * b = dynamic_cast<B *>(a); }catch(...){ } return 0; }
Скомпилируется ли следующий код? struct A { A() { throw 0; } };
Что будет выведено на экран в результате работы программы? #include <iostream> class A { public: explicit A(int _k = 10) {k = _k;} int k; }; int main() { A a = int(100); std::cout << a.k; }
Что произойдет после, если попытаться скомпилировать этот код? template<class T> class Object { public: Object(std::string& name, const T& value):nameVal(name), objectVal(value){}; ~Object(); private: std::string& nameVal; const T objectVal; }; std::string new("Good"); std::string old("Bad"); Object<int> p(new, 2); Object<int> s(old, 20); p = s;
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