All submissions

Manage a Device with a unique_ptr

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

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

int main() {
    // your code here: declare unique_ptr<Sensor> and call read() using ->p 
    unique_ptr<Sensor> p{new Sensor};
    cout << "Sensor reading: " << p->read() << "\n";
    return 0;
}
Loading...

Input

Expected Output

Sensor reading: 42