Define the exception class MemoryAllocationExceptand then revise the definition of the method pushin the class LinkedStackso that it throws this exception if it cannot allocate a new node.
What will be an ideal response?
```
#include
#include
classMemoryAllocationExcept: public exception
{
public:
MemoryAllocationExcept(conststd::string& message = "") :
exception("The operation push cannot allocate memory: " +
message.c_str())
{
} // end constructor
}; // end MemoryAllocationExcept
template
bool LinkedStack
throw(MemoryAllocationExcept )
{
try
{
Node
topPtr = newTopNode;
}
catch (bad_alloc e)
{
throw MemoryAllocationExcept("MemoryAllocationExcept : " +
"push() cannot allocate memory.");
} // end try/catch
return true;
} // end push
```
You might also like to view...
A back-end database file contains _________
Fill in the blank(s) with correct word
Word cannot be setup to always save the document in an older format, this action must be done individually for every document
Indicate whether the statement is true or false