所有程序可以正常运行 文件也可以正常写入打开 但再一次运行且程序涉及到数组就显示this指针为空(应该是读文件那一块有问题)
各位业界翘楚咋回事
#有关读文件
Manager::Manager()
{
ifstream ifsUser;
ifsUser.open(UserFILENAME, ios::in);
if (!ifsUser.is_open())
{
this->m_UserNum = 0;
this->m_UserArray = NULL;
this->NowID ="0";
this->m_UserFileIsEmpty = true;
ifsUser.close();
return;
}
char chUser;
ifsUser >> chUser;
if (ifsUser.eof())
{
this->m_UserNum = 0;
this->m_UserArray = NULL;
this->NowID = "0";
this->m_UserFileIsEmpty = true;
ifsUser.close();
return;
}
this->NowID = "0";
int numUser = this->get_UserNum();
this->m_UserNum = numUser;
this->m_UserArray = new User * [this->m_UserNum];
this->int_User();
}
int Manager::get_UserNum()
{
ifstream ifs;
ifs.open(UserFILENAME, ios::in);
string id;
string passwd;
int num = 0;
while (ifs >> id && ifs >> passwd)
{
num++;
}
return num;
}
void Manager::int_User()
{
ifstream ifs;
ifs.open(UserFILENAME, ios::in);
string id;
string passwd;
int index = 0;
while (ifs >> id && ifs >> passwd)
{
User* US = NULL;
this->m_UserArray[index] = US;
index++;
}
ifs.close();
}