home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!munnari.oz.au!comp.vuw.ac.nz!kauri.vuw.ac.nz!robertd
- From: robertd@kauri.vuw.ac.nz (Robert Davies)
- Subject: Borland, Microsoft and operator=()
- Nntp-Posting-Host: kauri.vuw.ac.nz
- Message-ID: <BzCnEA.260@comp.vuw.ac.nz>
- Organization: Victoria University of Wellington
- Sender: news@comp.vuw.ac.nz (News Admin)
- Date: Wed, 16 Dec 1992 11:18:10 GMT
- Lines: 45
-
- /*
- The following program displays "Borland" when run under Borland C++
- and "Microsoft" when run under Microsoft C++. The reason is that
- Borland uses the user defined version of operator= whereas Microsoft
- uses the default =. I presume the AT&T compiler and G++ will follow
- Borland.
-
- I can't find a revelant statement in the ARM or C++ reference manual.
- So who is right, or is this a matter for the standards committee?
-
- (Apologies if this has already been discussed to death)
-
- Robert
- */
-
-
-
- #include <iostream.h>
-
- char* borland = "Borland";
- char* microsoft = "Microsoft";
-
- class Base
- {
- public:
- char* c;
- Base() { c = microsoft; }
- };
-
- class Derived : public Base
- {
- public:
- void operator=(const Base&) { c = borland; }
- Derived() {}
- };
-
- main()
- {
- Derived d,e;
- e = d; // Borland uses operator= whereas
- // Microsoft uses the default =
- cout << e.c;
- return 0;
- }
-
-