All submissions

Object Pointer Access

#include <iostream>
using namespace std;

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

int main() {
    // declare Sensor object pointer
    Sensor* s = new Sensor;

    // assign value
    s->value = 88;

    // call printValue()
    s->printValue();

    // free memory
    delete s;

return 0;

}
Loading...

Input

Expected Output

Sensor Value: 88