[Solved] cout corrupt char* [closed]


You are passing a pointer to a local variable. Once your function ends, this variable is gone.

If this is C++ you should use the string class. If for whatever reason you don’t, at least be const correct:

const char* Worker::getName() const 
{
    return name;
}

1

solved cout corrupt char* [closed]