[comp.lang.c++] operator const char *

pdevries@watserv1.waterloo.edu (Peter DeVries) (05/05/90)

as an added item to the discussion about what to do with the 		
conversion operator 'char *'  in a string class.
 
Can I use   String::operator const char *(etc.)

I am trying to figure out a way to stop the use of something like.

String s("hello");

char buf[20] = "hi there";

strcpy(s,buf);    

from overwriting the internal character string in the string class if
the internal char * is returned from the conversion operator.

I just don't understand the nuances of returning a separate copy of the
character string from the conversion operator....

Peter DeVries
Mutual Life of Canada
c/o mgardi@watdcsu
(519) 888-3523
(416) 972-0594

My opinions/comments are mine, and mine only, and have nothing
to do with what Mutual Life of Canada thinks (now isn't that
an understatement!)
p.

-- 
Peter DeVries
Mutual Life of Canada
c/o mgardi@watdcsu
(519) 888-3523