implement string class with custom behavior
Posted
by
truman
on Stack Overflow
See other posts from Stack Overflow
or by truman
Published on 2011-01-04T03:50:28Z
Indexed on
2011/01/04
3:53 UTC
Read the original article
Hit count: 245
In one of our class sir said that template allows one to customize behavior of class, and then he gave example of string class, that with few lines of code we can customize string class from STL, as in, we can make it to treat 'a' and 'z' same, 'b' and 'y' same, 'c' and 'x' same and so on. Similary 'A' and 'Z' same etc.
"abc" == "zyx" is true;
"Abc" == "zyx" is false;
"Abc == "Zyx" is true;
etc
I was thinking of implementing such string class, but I am not able to do so. How can we implement such string class using templates?
© Stack Overflow or respective owner