← Back to Pointers
Question 704
Weather Station Struct Behind a unique_ptr
Weather Station Struct Behind a unique_ptr
TheStationstruct is already declared for you. Read a one-word city name and an integer temperature from standard input, create aunique_ptr<Station>withmake_unique, store both values in the struct through the pointer, then print three lines using->. For the inputDenver 31the program prints exactly the output shown in Expected Output. The third line prints1when the stored temperature is less than 32 and0otherwise. For the inputMiami 80the last line isFreezing: 0. Do not writedeleteand do not use a rawnew— this question checks for memory leaks.
Expected Output:
Station: Denver Temperature: 31 Freezing: 1
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.