question archive 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;
}
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;
}