title: Object property not changing as expected when using pointers in C++
body: <p>I'm trying to play some around with classes in C++. Coming from a Java world, they're slightly different.</p>
  
  <p>What I'm trying to do should be obvious: I have a class named <code>SomeClass</code>, which holds a single <code>int</code>. Then I have a class named <code>A</code>, which </p>
  
  <pre><code>// Create a class holding just an integer.
  class SomeClass {
      public:
  
          int _value;
  
          SomeClass(int value) {
              this-&gt;_value = value;
          }
  };
  
  class A {
  
      private:
          // The property _someClassPointer holds a pointer to a SomeClass object.
          SomeClass *_someClassPointer;
      public:
  
          // We can set a SomeClass instance as a property of the A class.
          void setSomeClass(SomeClass *someClassPointer) {
              // It copies the local pointer value to the property.
              this-&gt;_someClassPointer = someClassPointer;
          }
  
          // We can retrieve the integer that the SomeClass instance holds.
          // We're assuming _someClassPointer does not point to NULL.
          int getValueOfSomeClass() {
              this-&gt;_someClassPointer-&gt;_value;
          }
  };
  
  void setup() {
      Serial.begin(9600);
  }
  
  void loop() {
  
      // Instantiate SomeClass object with int(5) argument
      SomeClass someClass(5);
  
      Serial.println(someClass._value); // It prints 5, as expected
  
      // Instantiate an A object by its default constructor
      A a;
  
      // Pass the address of someClass to the method
      a.setSomeClass(&amp;someClass);
  
      // Set the value of someClass to 6
      someClass._value = 6;
  
      Serial.println(a.getValueOfSomeClass()); // It prints 0
  }
  </code></pre>
  
  <p>How come <code>0</code> is printed instead of <code>6</code>?</p>