#include #include class Command { char name; public: Command(char name); char getName() const; }; Command::Command(char name) { this->name = name; } char Command::getName() const { return name; } class CommandList { Command** commands; int commandCount; public: CommandList(const char* commands); ~CommandList(); void printAll() const; }; CommandList::CommandList(const char* commands) { commandCount = strlen(commands); this->commands = new Command*[commandCount]; for (int i = 0; i < commandCount; i++) { Command* ptr = new Command(commands[i]); this->commands[i] = ptr; } } CommandList::~CommandList() { for (int i = 0; i < commandCount; i++) delete commands[i]; delete[] commands; } void CommandList::printAll() const { for (int i = 0; i < commandCount; i++) std::cout << commands[i]->getName() << " "; std::cout << std::endl; } int main() { CommandList cl("abcdefghijklmnop"); cl.printAll(); }