▁and ▁replace , ▁and ▁a ▁function ▁for ▁obtain ing ▁sub strings . ▁An ▁ ▁can ▁be ▁constructed ▁from ▁a ▁C - style ▁string , ▁and ▁a ▁C - style ▁string ▁can ▁also ▁be ▁obtained ▁from ▁one . ▁ ▁The ▁individual ▁units ▁making ▁up ▁the ▁string ▁are ▁of ▁type ▁, ▁at ▁least ▁( and ▁almost ▁always ) ▁ 8 ▁bits ▁each . ▁In ▁modern ▁usage ▁these ▁are ▁often ▁not ▁" char acters ", ▁but ▁parts ▁of ▁a ▁mult ib y te ▁character ▁encoding ▁such ▁as ▁UTF - 8 . ▁ ▁The ▁copy - on - write ▁strategy ▁was ▁deliber ately ▁allowed ▁by ▁the ▁initial ▁C ++ ▁Standard ▁for ▁ ▁because ▁it ▁was ▁de emed ▁a ▁useful ▁optimization , ▁and ▁used ▁by ▁nearly ▁all ▁implementations . ▁However , ▁there ▁were ▁mistakes , ▁in ▁particular ▁the ▁ ▁returned ▁a ▁non - const ▁reference ▁in ▁order ▁to ▁make ▁it ▁easy ▁to ▁port ▁C ▁in - place ▁string ▁manip ulations ▁( such ▁code ▁often ▁assumed ▁one ▁byte ▁per ▁character ▁and ▁thus ▁this ▁may ▁not ▁have ▁been ▁a ▁good ▁idea !) ▁This ▁allowed ▁the ▁following ▁code ▁that ▁shows ▁that ▁it ▁must ▁make ▁a ▁copy ▁even ▁though ▁it ▁is ▁almost ▁always ▁used ▁only ▁to ▁examine ▁the ▁string ▁and ▁not ▁modify ▁it : ▁▁▁ ▁std :: string ▁original (" aaaa aa a "); ▁▁ ▁std :: string ▁string _ copy ▁= ▁original ; ▁// ▁make ▁a ▁copy ▁▁ ▁char * ▁pointer ▁= ▁& string _ copy [ 3 ]; ▁// ▁some ▁tried ▁to ▁make ▁operator [] ▁return ▁a ▁" tr ick