// word.cpp #include "word.h" #include Word::Word(const char* p) : _word(0) { set(p); } Word::~Word() { delete [] _word; } void Word::set(const char* p) { delete [] _word; _word = 0; if (p) { _word = new char [strlen(p) + 1]; strcpy(_word, p); } } char* Word::reverse() const { char* p = 0; if (_word) { int len = strlen(_word); p = new char [len + 1]; for (int i = 0; i < len; i++) p[i] = _word[len - i - 1]; p[len] = 0; } return p; }