C question Here are several different initializations of a s

C++ question

Here are several different initializations of a structure variable. Clearly describe what happens with the member values in the variable (object) prediction, after each initialization in the main function. struct WeatherData {int temperature; int windChill; int windSpeed;}; WeatherData prediction = {0} WeatherData prediction = {-80}; WeatherData prediction = {-80, -26} WeatherData prediction = {-80, -25, 55};

Solution

a) in this case only one argument is there hence first member is initialized to zero i.e temperature =0

b) same as case a) temperature=-80

c) first 2 members are initialized .. temperature=-80

windChill=-26

d) all are initialized

temperature=-80

windChill=-25

windSpeed=55

C++ question Here are several different initializations of a structure variable. Clearly describe what happens with the member values in the variable (object) p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site