question archive C++ Allocating Memory Allocate memory for houseHeight using the new operator

C++ Allocating Memory Allocate memory for houseHeight using the new operator

Subject:Computer SciencePrice:2.85 Bought3

C++ Allocating Memory

Allocate memory for houseHeight using the new operator.

#include <iostream>
using namespace std;

int main() {
double* houseHeight = nullptr;

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

return 0;
}

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Highlighted the code with new operator

#include <iostream>
using namespace std;

int main() {
double* houseHeight = nullptr;

houseHeight = new double;

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

return 0;
}