42. What is the purpose of the 'std::unexpected' function in C++ exception handling?
43. Which statement about exception handling in C++ is true?
44. What is the behavior of the 'std::terminate' function in C++?
45. Uncaught exception leads to . . . . . . . .
46. What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
void func(int a, int b)
{
if(b == 0){
throw "This value of b will make the product zero. "
"So please provide positive values.\n";
}
else{
cout<<"Product of "<<a<<" and "<<b<<" is: "<<a*b<<endl;
}
}
int main()
{
try{
func(5,0);
}
catch(const char* e){
cout<<e;
}
}
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
void func(int a, int b)
{
if(b == 0){
throw "This value of b will make the product zero. "
"So please provide positive values.\n";
}
else{
cout<<"Product of "<<a<<" and "<<b<<" is: "<<a*b<<endl;
}
}
int main()
{
try{
func(5,0);
}
catch(const char* e){
cout<<e;
}
}