Which operations don't throw anything?
What do you mean by "No exception specification"?
What is the output of this program?
1. #include2. using namespace std; 3. int main() 4. { 5. char* ptr; 6. unsigned long int Test = sizeof(size_t(0) / 3); 7. cout << Test << endl; 8. try 9. { 10. ptr = new char[size_t(0) / 3]; 11. delete[ ] ptr; 12. } 13. catch (bad_alloc &thebadallocation) 14. { 15. cout << thebadallocation.what() << endl; 16. }; 17. return 0; 18. }
What is the output of this program?
1. #include2. #include 3. using namespace std; 4. class Myshape 5. { 6. public: 7. virtual void myvirtualfunc() const {} 8. }; 9. class mytriangle: public Myshape 10. { 11. public: 12. virtual void myvirtualfunc() const 13. { 14. }; 15. }; 16. int main() 17. { 18. Myshape Myshape_instance; 19. Myshape &ref_Myshape = Myshape_instance; 20. try 21. { 22. mytriangle &ref_mytriangle = dynamic_cast (ref_Myshape); 23. } 24. catch (bad_cast) 25. { 26. cout << "Can't do the dynamic_cast lor!!!" << endl; 27. cout << "Caught: bad_cast exception. Myshape is not mytriangle.n"; 28. } 29. return 0; 30. }
What is the output of this program?
1. #include2. #include 3. #include 4. using namespace std; 5. int main( ) 6. { 7. try 8. { 9. string strg1("Test"); 10. string strg2("ing"); 11. strg1.append(strg2, 4, 2); 12. cout << strg1 << endl; 13. } 14. catch (exception &e) 15. { 16. cout << "Caught: " << e.what() << endl; 17. cout << "Type: " << typeid(e).name() << endl; 18. }; 19. return 0; 20. }