Manage a Device with a unique_ptr

#include <iostream>
#include <memory>
using namespace std;

class Sensor {
public:
    int read() { return 42; }
};

int main() {
    unique_ptr<Sensor> sensor = make_unique<Sensor>();
    cout << "Sensor reading: " << sensor->read();
    // your code here: declare unique_ptr<Sensor> and call read() using ->
    return 0;
}
Upvote
Downvote
Loading...

Input

Expected Output

Sensor reading: 42