Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / 1

1

Computer Science

1. Allocate memory for houseHeight using the new operator.

#include <iostream>
using namespace std;

int main() {
double* houseHeight = 0;

/* Your solution goes here */

*houseHeight = 23;
cout << "houseHeight is " << *houseHeight;

return 0;
}

2. Deallocate memory for kitchenPaint using the delete operator.

#include <iostream>
using namespace std;

class PaintContainer {
public:
~PaintContainer();
double gallonPaint;
};

PaintContainer::~PaintContainer() { // Covered in section on Destructors.
cout << "PaintContainer deallocated." << endl;
return;
}

int main() {
PaintContainer* kitchenPaint;

kitchenPaint = new PaintContainer;
kitchenPaint->gallonPaint = 26.3;

/* Your solution goes here */

return 0;
}

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

#include <iostream>
using namespace std;
int main() {
double* houseHeight = 0;
/* Your solution goes here */
houseHeight = new double;
*houseHeight = 23;
cout << "houseHeight is " << *houseHeight;
return 0;
}

#include <iostream>
using namespace std;
class PaintContainer {
public:
~PaintContainer();
double gallonPaint;
};
PaintContainer::~PaintContainer() { // Covered in section on Destructors.
cout << "PaintContainer deallocated." << endl;
return;
}
int main() {
PaintContainer* kitchenPaint;
kitchenPaint = new PaintContainer;
kitchenPaint->gallonPaint = 26.3;
/* Your solution goes here */
delete kitchenPaint;
return 0;
}