the bad_function_call is a class in which an exception type thrown when a instance of a function object is empty when invoked and it is exception thrown by boost::exception::operator().The main objective of the bad_call_function is that none of the function should be null because it will effect the program in implementation. there is pictorial representation of the inheritance of exception of bad_function_call:
Syntax:
boost::bad_function_call &exception_variable
Member functions:
constructor():it constructs a bad_function_call exception object and it is public member function.
bad_function_call().
destructor( ): it destroys a bad_function_call exception object and it is virtual public member function.
~bad_function_call( )
what() : this function return the meaning full explanatory string of the exception.
program:
#include<boost/function.hpp> // the main header file we have use#include<iostream>intmain(){
try
{
boost::function<int(constchar*)> f;
f(""); // AS WE CAN SEE THAT THE F IS EMPTY OR IT CAN BE BY USING NULLPTR IN FUNCTION f THERE IS NOTHIMG
}
catch (boost::bad_function_call &ex)// HERE THE EXCEPTION IS BEEN THROWN
{
std::cout << ex.what() << '\n';// WHAT IS THE FUNCTION SENDS THE EXPLANATORY STRING
}
}
Comments