home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16000 < prev    next >
Encoding:
Text File  |  1992-11-09  |  819 b   |  39 lines

  1. Path: sparky!uunet!usc!news!iat.holonet.net!agate!doc.ic.ac.uk!uknet!mcsun!sun4nl!media03!pkr
  2. From: pkr@media03.UUCP (Peter Kriens)
  3. Newsgroups: comp.lang.c++
  4. Subject: stupid bug with NIHCL & sun ompiler
  5. Message-ID: <2895@media03.UUCP>
  6. Date: 9 Nov 92 21:12:55 GMT
  7. Organization: Mediasystemen, Netherlands
  8. Lines: 28
  9. X-Newsreader: Tin 1.1 PL4
  10.  
  11.  
  12. I am looking for people who could help me on the
  13. following puzzling problem:
  14.  
  15. class A {
  16. public:
  17.     String s;
  18.     [virtual] void t();
  19. };
  20.  
  21. main()
  22. {
  23.     A a,b;
  24.     a.s="abc";
  25.     b.s="def";
  26.     a = b;
  27. }
  28.  
  29. without the virtual, no problem C++ uses the = operator for
  30. s from the String class and a new pointer is created.
  31.  
  32. with the virtual operator, it uses a bit wise assignment
  33. and a.s will now point to the same memory location
  34. as b.s. Problems!
  35.  
  36. Anybody knows something about this?
  37.  
  38.     Peter Kriens
  39.