home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18422 < prev    next >
Encoding:
Text File  |  1992-12-25  |  1.0 KB  |  46 lines

  1. Path: sparky!uunet!wupost!waikato.ac.nz!comp.vuw.ac.nz!kauri.vuw.ac.nz!robertd
  2. Newsgroups: comp.lang.c++
  3. Subject: Microsoft C++ bug
  4. Message-ID: <BztCvC.7KE@comp.vuw.ac.nz>
  5. From: robertd@kauri.vuw.ac.nz (Robert Davies)
  6. Date: Fri, 25 Dec 1992 11:50:00 GMT
  7. Sender: news@comp.vuw.ac.nz (News Admin)
  8. Organization: Victoria University of Wellington
  9. Nntp-Posting-Host: kauri.vuw.ac.nz
  10. Lines: 34
  11.  
  12. /*
  13. Strange microsoft bug
  14.  
  15. The following program calls the constructor for Base once and the destructor
  16. twice.
  17.  
  18. It works fine with Borland.
  19. */
  20.  
  21. #include <iostream.h>
  22.  
  23. class Derived;
  24.  
  25. class Base
  26. {
  27. public:
  28.    Base()
  29.       { cout << "Constructer called; this = " << (unsigned long)this << "\n"; }
  30.    ~Base()
  31.       { cout << "Destructor  called; this = " << (unsigned long)this << "\n"; }
  32.  
  33.    operator Derived() const;       // OK if this statement is omitted
  34. };
  35.  
  36. class Derived : public Base        // OK if not derived from Base
  37. {};
  38.  
  39. class AnotherClass
  40. {
  41. public:
  42.    AnotherClass(const Base&) {}
  43. };
  44.  
  45. main()  {  Base M;    AnotherClass C(M);   return 0;  }
  46.