implementing operator== when using inheritance
<p>I have a base class which implements the == operator.
I want to write another class, inheriting the base class, and which should reimplement the == operator.</p>

<p>Here is some sample code :</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

class Person
{
public:
  Person(std::string Name) { m_Name = Name; };

  bool operator==(const Person&amp; rPerson)
  {
    return m_Name == rPerson.m_Name;
  }

private:
  std::string m_Name;
};

class Employee : public Person
{
public:
  Employee(std::string Name, int Id) : Person(Name) { m_Id = Id; };

  bool operator==(const Employee&amp; rEmployee)
  {

    return (Person::operator==(rEmployee)) &amp;&amp; (m_Id == rEmployee.m_Id);
  }

private:
  int m_Id;
};

void main()
{
  Employee* pEmployee1 = new Employee("Foo" , 1);
  Employee* pEmployee2 = new Employee("Foo" , 2);

  if (*pEmployee1 == *pEmployee2)
  {
    std::cout &lt;&lt; "same employee\n";
  }
  else
  {
    std::cout &lt;&lt; "different employee\n";
  }

  Person* pPerson1 = pEmployee1;
  Person* pPerson2 = pEmployee2;

  if (*pPerson1 == *pPerson2)
  {
    std::cout &lt;&lt; "same person\n";
  }
  else
  {
    std::cout &lt;&lt; "different person\n";
  }
}
</code></pre>

<p>This sample code give the following result :</p>

<pre><code>different employee
same person
</code></pre>

<p>Where I would like, even when handling Person* pointers, to make sure they are different.</p>

<p>How am I supposed to solve this problem ?</p>

<p>Thanks !</p>
