home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!microsoft!hexnut!jimad
- From: jimad@microsoft.com (Jim Adcock)
- Subject: Re: Automatic conversion! Can we do this?
- Message-ID: <1992Dec24.185906.23522@microsoft.com>
- Date: 24 Dec 92 18:59:06 GMT
- Organization: Microsoft Corporation
- References: <1h7sq8INNr7e@function.mps.ohio-state.edu>
- Lines: 17
-
- In article <1h7sq8INNr7e@function.mps.ohio-state.edu> ren@function.mps.ohio-state.edu (Liming Ren) writes:
- |string a, b("Merry");
- |a=b+" Chrismas";
- |a="C" + b;
- |
- |But I can't do: a="Merry" + " Chrismas";
- |The compiler complains that "pointer +pointer" and the conversion does not
- |happen. I tried to overload + with (char*, char*). The compiler did not
- |allow me.
-
- The language does not allow you to do this. Overloaded operators must
- take at least one parm of class type. (ptr + ptr) is defined to be an error
- by the language and you cannot overload this behavior because of the previous
- rule. The closest you can come is:
-
- a = (string) "Merry" + " Christmas";
-
-