Turing machine implementation in C++ with a palindrome automaton example