functional::bad_function_call in C++ with Examples Last Updated : 15 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Standard C++ contains several built-in exception classes, functional::bad_function_call is one of them. This is an exception thrown on bad call. Below is the syntax for the same: Header File: include<functional> Syntax: class bad_function_call; Note: To make use of functional::bad_function_call, one should set up the appropriate try and catch blocks. Below are the programs to understand the implementation of functional::bad_function_call in a better way: Program 1 : CPP14 // C++ code for functional::bad_function_call #include <bits/stdc++.h> using namespace std; // main method int main() { function<int()> gfg = nullptr; // try block try { gfg(); } // catch block to handle the errors catch (const bad_function_call& geeksforgeeks) { cout << geeksforgeeks.what() << endl; } return 0; } Output: bad_function_call Example 2 : CPP14 // C++ code for functional::bad_function_call #include <bits/stdc++.h> using namespace std; // main method int main() { function<int()> geeksforgeeks = nullptr; // try block try { geeksforgeeks(); } // catch block to handle the errors catch (const bad_function_call& gfg) { cout << gfg.what() << endl; } return 0; } Output: bad_function_call Reference: https://cplusplus.com/reference/functional/bad_function_call/ Comment More infoAdvertise with us Next Article ios clear() function in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Functions Practice Tags : CPPMisc Similar Reads ios bad() function in C++ with Examples The bad() method of ios class in C++ is used to check if the stream is has raised any bad error. It means that this function will check if this stream has its badbit set. Syntax: bool bad() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if the st 1 min read ios bad() function in C++ with Examples The bad() method of ios class in C++ is used to check if the stream is has raised any bad error. It means that this function will check if this stream has its badbit set. Syntax: bool bad() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if the st 1 min read exception::bad_exception in C++ with Examples Standard C++ contains several built-in exception classes, exception::bad_exception is one of them. This is an exception thrown by unexpected handler. Below is the syntax for the same: Header File: include<exception> Syntax: class bad_exception; Return: The exception::bad_exception returns a nu 2 min read ios clear() function in C++ with Examples The clear() method of ios class in C++ is used to change the current state of the specified flag by setting it. Hence this function changes the internal state of this stream. Syntax: void clear(iostate state) Parameters: This method accepts the iostate as parameter which is the flag bit to be set in 2 min read ios clear() function in C++ with Examples The clear() method of ios class in C++ is used to change the current state of the specified flag by setting it. Hence this function changes the internal state of this stream. Syntax: void clear(iostate state) Parameters: This method accepts the iostate as parameter which is the flag bit to be set in 2 min read ios fail() function in C++ with Examples The fail() method of ios class in C++ is used to check if the stream is has raised any fail error. It means that this function will check if this stream has its failbit set. Syntax: bool fail() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if th 1 min read Like