CJCoding With Joseph
15free / daySign inCreate account

Weather Station Struct Behind a unique_ptr

The Station struct is already declared for you. Read a one-word city name and an integer temperature from standard input, create a unique_ptr<Station> with make_unique, store both values in the struct through the pointer, then print three lines using ->.

For the input Denver 31 the program prints exactly the output shown in Expected Output.

The third line prints 1 when the stored temperature is less than 32 and 0 otherwise. For the input Miami 80 the last line is Freezing: 0.

Do not write delete and do not use a raw new — 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
Topics:
Pointers
📥 Auto-Input:
Denver 31\n
This input is automatically fed to your program's stdin
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.