c++构造函数不明求解

教程上的一段范例程序,vs2017调试后可以运行,显示输出的结果不是我要的值;使用g++调试的话,会提示无法定位程序输入点,哪位大佬帮忙看看,具体是哪里的问题。程序代码如下:
 

main.cpp

#include<iostream>
#include"CPersonV1.h"

using namespace std;

int main()
{
    string str="tony";
    CPerson p1;
    CPerson p2 = CPerson(1,str,25,8000);
    cout << "p1的信息:" << endl;
    cout << "m_shAge is : " << p1.getAge() << endl;
    cout << "m_iIndex is : " << p1.getIndex() << endl;
    cout << "m_sName is : " << p1.getName() << endl;
    cout << "m_dSalary is : " << p1.getSalary() << endl;
    cout << "p2的信息:" << endl;
    cout << "m_shAge is : " << p2.getAge() << endl;
    cout << "m_iIndex is : " << p2.getIndex() << endl;
    cout << "m_sName is : " << p2.getName() << endl;
    cout << "m_dSalary is : " << p2.getSalary() << endl;
    
}

CPersonV1.h

#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;

class CPerson
{
public:
    //构造函数
    CPerson(int index, string name, short age, double salary);

    CPerson();
    
    //数据成员
    int m_iIndex;
    string m_sName;
    short m_shAge;
    double m_dSalary;

    //成员函数
    short getAge();
    int setAge(short sAge);
    int getIndex();
    int setIndex(int iIndex);
    string getName();
    int setName(string sName);
    double getSalary();
    int setSalary(double dSalary);
};

    //类成员函数的实现部分

short CPerson::getAge()
{
    return m_shAge;
}

int CPerson::getIndex()
{
    return m_iIndex;
}

string CPerson::getName()
{
    return m_sName;
}

double CPerson::getSalary()
{
    return m_dSalary;
}

//构造函数
CPerson::CPerson()
{
    //数据成员
    int m_iIndex = 1;
    string m_sName ="Mary";
    short m_shAge = 25;
    double m_dSalary = 8000;
}
CPerson::CPerson(int index, string name, short age, double salary)
{
    //数据成员
    int m_iIndex = index;
    string m_sName = name;
    short m_shAge = age;
    double m_dSalary = salary;
}

 

/构造函数
CPerson::CPerson()
{
    //数据成员
    m_iIndex = 1;
    m_sName ="Mary";
    m_shAge = 25;
    m_dSalary = 8000;
}
CPerson::CPerson(int index, string name, short age, double salary)
{
    //数据成员
    m_iIndex = index;
    m_sName = name;
    m_shAge = age;
    m_dSalary = salary;
}

你的程序中只是给函数内部局部进行赋值,而类成员却没有赋值

函数里面加了数据类型后,编译器会认为这是个局部变量,不加的时候才会找成员变量里面找