Final answer:
To deallocate the memory assigned to a dynamic variable in C++, the 'delete' operator is used. The 'new' operator allocates memory for an object and returns a pointer, throwing 'bad_alloc' on failure or a null pointer when using the 'nothrow' variant.
Step-by-step explanation:
To destroy a dynamically allocated variable and return its memory to the free store manager, you can use the delete operator. Here is how you would do it for the variable x that was created:
delete x;
This line of code deallocates the memory that x points to and returns it to the pool of available memory, allowing for the creation of other dynamic variables.
About the new Operator
The new operator in C++ is used for dynamic memory allocation. It allocates memory for a single object or an array of objects of a given type and returns a pointer to the first byte of the allocated space. The new operator does two things: it allocates memory and then calls the constructor (for non-primitive data types). If the allocation is successful, it returns a pointer to the allocated memory. However, if it fails to allocate memory, in C++ prior to C++11, it throws a bad_alloc exception or, in the case of using the nothrow version of new, returns a null pointer.