I'm having problem with getting the value of class member after assigning like that:
bool ModeData::setPasswd(char* _pass)
{
return (this->setString(this->passwd_, _pass) ? true : false);
}
bool ModeData::setOutput(char* _out)
{
return (this->setString(this->output_, _out) ? true : false);
}
where setString is like that:
bool ModeData::setString(char* _toStr, char* _fromStr)
{
// check if already exists and delete
this->delIfPresent(_toStr);
// allocate space for the new string
_toStr = new char[strlen(_fromStr) + 1];
// copy new string
if(strcpy(_toStr, _fromStr))
{
return true;
}
// if something gone wrong return 'false'
return false;
}
and then if I want to print the value of this->passwd_, I get nothing. I think the pointers are lost somewhere when passing through methods, but I'm not sure.