Object Pointer Access

#include <iostream>
using namespace std;

class Sensor {
public:
    int value;
    void printValue() {
        cout << "Sensor Value: " << value << "\n";
    }
};

int main() {

    // your code here: declare Sensor object pointer, assign value, and call printValue()

    Sensor *p;
    Sensor s;

    p = &s;

    p->value = 88;
    p->printValue();
    
    return 0;
}
Upvote
Downvote
Loading...

Input

Expected Output

Sensor Value: 88