A function takes const Text& and just wants to read characters. It does not compile: the only operator[] in the class is non-const, and a const object is not allowed to call it. You need two versions of the operator — the compiler will pick the right one itself.
t[i] does not compile when t is const — the class only has a non-const operator[]. Add a second, const overload of operator[] so const objects can read. Writing through a const object must stay impossible.
t[i] must work for both Text and const Textt[i] = c must work for a mutable Textconst Text must NOT compileconst_cast and do not make fields mutableconst?char& the right return type for the non-const overload?Two methods may share a name and parameters and differ only in a trailing const — that is a legal overload pair.
Think about what the const version returns: if it hands out a plain char&, writing through a const object would still compile.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.