In modern C++, that is C++17, I would use std::string_view in your display function. So:

void display(std::string_view text)
{
for (const auto& t : text) {
std::cout <<...