home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19944 < prev    next >
Encoding:
Internet Message Format  |  1993-01-27  |  988 b 

  1. 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
  2. From: gs4t@virginia.edu (Gnanasekaran Swaminathan)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: operator = with inheritance
  5. Message-ID: <1993Jan26.194448.15469@murdoch.acc.Virginia.EDU>
  6. Date: 26 Jan 93 19:44:48 GMT
  7. References: <1993Jan14.185649.21213@virginia.edu> <1993Jan26.175530.1382@PacBell.COM>
  8. Sender: usenet@murdoch.acc.Virginia.EDU
  9. Organization: University of Virginia
  10. Lines: 13
  11.  
  12. pjcondi@ns.pacbell.com (Paul Condie) writes:
  13. :     A * obj3 = new B (1);
  14. :     A * obj4 = new B;
  15. :     *obj4 = *obj3;            // works for pointer types
  16.  
  17. The problem then becomes how does one prevent the following
  18. or better yet how does one handle gracefully the following:
  19.     A a;
  20.     *obj4 = &a; // call B::operator = (const A&)
  21.  
  22. The solution that you provided casts an A object
  23. into a B object with surprising results.
  24.