title: A private variable can be accessed from another object of the same type?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7396846/with-a-private-modifier-why-can-the-member-in-other-objects-be-accessed-directl">With a private modifier, why can the member in other objects be accessed directly?</a>  </p>
  </blockquote>
  
  
  
  <p>Private members of a C++ class are designed to be invisible to other class instances. I'm confused since private members <em>can</em> be accessed as shown below! Can anyone explain it to me?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;iostream&gt; 
  using namespace std; 
  class Person
  {
  private:
      char* name;
      int age;
  public:
      Person(char* nameTemp, int ageTemp)
      {
        name = new char[strlen(nameTemp) + 1];
        strcpy(name, nameTemp);
        age = ageTemp;
      }
      ~Person()
      {
        if(name != NULL)
          delete[] name;
        name = NULL;
      }
      bool Compare(Person&amp; p)
      {
        //p can access the private param: p
        //this is where confused me
        if(this-&gt;age &lt; p.age) return false;
          return true;
      }
  };
  int main() 
  { 
    Person p("Hello, world!", 23);
    return 0; 
  }
  </code></pre>