Question: How to determine below in which memory area. Please explain in detail. - Memory Area 1: Environment - Memory Area 2: Runtime Stack - Memory

How to determine below in which memory area. Please explain in detail.

- Memory Area 1: Environment

- Memory Area 2: Runtime Stack

- Memory Area 3: Free-store

- Memory Area 4A: Uninitialized Data

- Memory Area 4B: Initialized Data

- Memory Area 5: Binary Program

#include

#include

using namespace std;

static string model;

class Car {

public:

Car() {};

static string carModel;

string name{ "McQueen" };

};

string Car::carModel = "S";

Car* testCar(string str) {

unique_ptr uCarPtr { make_unique() };

static Car car;

Car* driverlessCar = new Car();

return &car;

}

function testLambda() {

int price = 100000;

int rank = 1;

function carLambda = [rank, &price]()->int {

cout << "carLambda in testLambda" << endl;

return price + rank;

};

return carLambda;

}

int main(int argc, char* argv[], char* envp[]) {

Car* carPtr = testCar("CS");

string carName{ carPtr->name };

model = Car::carModel;

auto testLambdaPtr = testLambda();

cout << testLambdaPtr() << endl;

return 0;

}

a.In which memory area is this element stored? Please state your choice and explain why?

b.The lifetime, beginning & end, of this element? Why?

uCarPtr object[1] [2] [3] [4a] [4b] [5]

Why [area]?

What lifetime and why?

carLambda expression [1] [2] [3] [4a] [4b] [5]

Why [area]?

What lifetime and why?

testLambdaPtr object [1] [2] [3] [4a] [4b] [5]

Why [area]?

What lifetime and why?

envp[1] [2] [3] [4a] [4b] [5]

Why [area]?

What lifetime and why?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!