subject

You are provided with the following program poem. cpp. All is good, and the memory is allocated dynamically, but it crashes your computer, because it runs out of memory really quickly:

#include
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();

// assume that the poem p is not needed at this point

}
}
Fix this program poem. cpp. It should still keep creating poems, but all dynamically allocated memory should get deleted when it is not needed.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:20
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
question
Computers and Technology, 23.06.2019 21:00
Uget brainliest if accurate mary has been given the responsibility of hiring a person for the position of a software testing officer. which management function would mary achieve this responsibility?
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Which steps will open the system so that you can enter a question and do a search for
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
Auniform resource locator (url) is a formatted string of text that web browsers, email applications, and other software programs use to identify a particular resource on the internet. true false
Answers: 2
You know the right answer?
You are provided with the following program poem. cpp. All is good, and the memory is allocated dyna...
Questions
question
Biology, 01.04.2020 06:44
question
World Languages, 01.04.2020 06:45
question
Mathematics, 01.04.2020 06:45
question
Mathematics, 01.04.2020 06:45
question
Mathematics, 01.04.2020 06:45
question
Mathematics, 01.04.2020 06:45
Questions on the website: 13722363