home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!waikato.ac.nz!comp.vuw.ac.nz!kauri.vuw.ac.nz!robertd
- Newsgroups: comp.lang.c++
- Subject: Microsoft C++ bug
- Message-ID: <BztCvC.7KE@comp.vuw.ac.nz>
- From: robertd@kauri.vuw.ac.nz (Robert Davies)
- Date: Fri, 25 Dec 1992 11:50:00 GMT
- Sender: news@comp.vuw.ac.nz (News Admin)
- Organization: Victoria University of Wellington
- Nntp-Posting-Host: kauri.vuw.ac.nz
- Lines: 34
-
- /*
- Strange microsoft bug
-
- The following program calls the constructor for Base once and the destructor
- twice.
-
- It works fine with Borland.
- */
-
- #include <iostream.h>
-
- class Derived;
-
- class Base
- {
- public:
- Base()
- { cout << "Constructer called; this = " << (unsigned long)this << "\n"; }
- ~Base()
- { cout << "Destructor called; this = " << (unsigned long)this << "\n"; }
-
- operator Derived() const; // OK if this statement is omitted
- };
-
- class Derived : public Base // OK if not derived from Base
- {};
-
- class AnotherClass
- {
- public:
- AnotherClass(const Base&) {}
- };
-
- main() { Base M; AnotherClass C(M); return 0; }
-