C++类和对象之重载问题

在自学C++关系运算符重载课程的时候,已经重载好了全等符,创建了两个不等的对象,运行还是显示两个对象相等
#include<iostream>
using namespace std; 
//重载关系运算符  

class pers
{
public:
    pers(string name, int age)
    {
        name = m_name;
        age = m_age;
    }
    //重载==号
    bool operator==(pers& p)
    {
        if (this->m_name == p.m_name && this->m_age == p.m_age)
        {
            return true;
        }

        return false;



    }
    bool operator!=(pers& p)
    {
        if (this->m_name == p.m_name || this->m_age == p.m_age)
        {
            return false;
        }

        return true;


    }
    string m_name;
    int m_age;
};

void test897909()
{
    pers p1("tom", 18);
    pers p2("uihlj", 28);
    if (p1 == p2)
    {
        cout << "p1和p2是相等的" << endl;
    }
    else
    {
        cout << "p1和p2是不相等的" << endl;
    }
    if (p1 != p3)
    {
        cout << "p1和p2是不相等的" << endl;

    }
    else
    {
        cout << "p1和p2是相等的" << endl;
    }
}
int main()
{
    test897909();




    system("pause");
    return 0;
}

运行结果及报错内容

p1与p2相等

我的解答思路和尝试过的方法

跟着网课学的,一模一样的代码怎么搞都是p1和p2相等

我想要达到的结果

怎么才能正常输出p1和p2不相等的结果

大哥 你是笔误把~

img

#include<iostream>
using namespace std;
//重载关系运算符

class pers
{
public:
    pers(string name, int age)
    {
        name = m_name;
        age = m_age;
    }
    //重载==号
    bool operator==(pers& p)
    {
        if (this->m_name == p.m_name && this->m_age == p.m_age)
        {
            return true;
        }

        return false;



    }
    bool operator!=(pers& p)
    {
        if (this->m_name == p.m_name || this->m_age == p.m_age)
        {
            return false;
        }

        return true;


    }
    string m_name;
    int m_age;
};

void test897909()
{
    pers p1("tom", 18);
    pers p2("uihlj", 28);
    if (p1 == p2)
    {
        cout << "p1和p2是相等的" << endl;
    }
    else
    {
        cout << "p1和p2是不相等的" << endl;
    }

}
int main()
{
    test897909();




    system("pause");
    return 0;
}

效果:

img