home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!opl.com!hri.com!noc.near.net!news.Brown.EDU!qt.cs.utexas.edu!cs.utexas.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!uvaarpa!murdoch!virginia.edu!gs4t
- From: gs4t@virginia.edu (Gnanasekaran Swaminathan)
- Newsgroups: comp.lang.c++
- Subject: Re: operator = with inheritance
- Message-ID: <1993Jan26.194448.15469@murdoch.acc.Virginia.EDU>
- Date: 26 Jan 93 19:44:48 GMT
- References: <1993Jan14.185649.21213@virginia.edu> <1993Jan26.175530.1382@PacBell.COM>
- Sender: usenet@murdoch.acc.Virginia.EDU
- Organization: University of Virginia
- Lines: 13
-
- pjcondi@ns.pacbell.com (Paul Condie) writes:
- : A * obj3 = new B (1);
- : A * obj4 = new B;
- :
- : *obj4 = *obj3; // works for pointer types
-
- The problem then becomes how does one prevent the following
- or better yet how does one handle gracefully the following:
- A a;
- *obj4 = &a; // call B::operator = (const A&)
-
- The solution that you provided casts an A object
- into a B object with surprising results.
-