l-value substr method in C++
I want to create a substr method in C++ in a string class that i made.

The string class is based on C-style string of course, and I take care of the memory managment.
I want to write a substr(start, length) function that can work on the regular way:

CustomString mystring = "Hello";

cout << mystring.substr(0,2); // will print "He"

and also in this way:

mystring.substr(1,3) = "DD"; // mystring will be "HDDo"

Notice that even though I get a 3 chars long substring, I put in the assigment only 2 chars and the output string will be HDDo, still.

Any idea how to get this done?

Thanks! 
l-value substr method in C++
===

I want to create a substr method in C++ in a string class that i made.

The string class is based on C-style string of course, and I take care of the memory managment.
I want to write a substr(start, length) function that can work on the regular way:

CustomString mystring = "Hello";

cout << mystring.substr(0,2); // will print "He"

and also in this way:

mystring.substr(1,3) = "DD"; // mystring will be "HDDo"

Notice that even though I get a 3 chars long substring, I put in the assigment only 2 chars and the output string will be HDDo, still.

Any idea how to get this done?

Thanks! 