Is there a way to have a trimmed() function for String?

yes, using String::String inherits all constructors and the assignment operator (=) from the String class, allowing MyString to be initialized and assigned in the same ways as String.

You could also have using String::methodName which makes all methods named methodName from the String class available in MyString. ( If the derived class has methods that override or hide methods from the base class, using using BaseClass::methodName makes all versions of that method from the base class visible and accessible in the derived class. This is useful when you want to ensure that derived class objects can use the base class's method signatures without ambiguity)