B
belief
I write a non-template simple string with the technique
that giving the same string a same storage with a count.
so i must give the necessary copy operation when the string will be
modified, I differ the two kinds of operator[] s.
// const object to use as const
const char& operator[] const
{
//directly get the ref
}
char& operator[]
{
// first copy. then give the new copy 's ref
}
but you see, when I just want to get the value ,not to modify it, a
unnecessary copy ocurrs.
Is there some methods to avoid this ?
Thanks.
that giving the same string a same storage with a count.
so i must give the necessary copy operation when the string will be
modified, I differ the two kinds of operator[] s.
// const object to use as const
const char& operator[] const
{
//directly get the ref
}
char& operator[]
{
// first copy. then give the new copy 's ref
}
but you see, when I just want to get the value ,not to modify it, a
unnecessary copy ocurrs.
Is there some methods to avoid this ?
Thanks.