title: Pointer to Object
body: <p>the code is running properly but I just wondering why calling function Show() by using pointer can return the value of x, y, z to the objectA, why not the address? Because the pointer stored the address. But how can it give value to the function Show()?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class _3D {
      double x, y, z;
  public:
      _3D(); 
      _3D(double initX, double initY, double initZ);
  
  void Show() {
          cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; " " &lt;&lt; z &lt;&lt; "\n";
      }
  };
  
  // Overloaded constructor
  _3D::_3D(double initX, double initY, double initZ) {
      x = initX;
      y = initY;
      z = initZ;
      cout &lt;&lt; "With arguments!!!\n";
  }
  
  // Class _3D constructor without arguments
  _3D::_3D() {
      x = y = z = 0;
      cout &lt;&lt; "No arguments!!!\n";
  }
  
  void main() {
      _3D A(3, 4, 0);
      _3D B;
  
  // Creating a pointer and adding with the A object's address to the object of _3D type
      _3D*PA = &amp;A;
  
      // Calling the function Show()
      PA-&gt;Show();
  
  
      system("pause");
  }
  </code></pre>