Answer:
See explaination
Step-by-step explanation:
#include <iostream>
using namespace std;
string * createAPoemDynamically()
{
string *p = new string;
*p = "Roses are red, violets are blue";
return p;
}
int main() {
while(true) {
string *p;
p = createAPoemDynamically();
if (!p)
{
cout << "Memory allocation failed\\";
}
cout<<*p<<"\\";
// assume that the poem p is not needed at this point
//delete allocated memory
delete p;
}
}