🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1259

Borland, Microsoft and operator=()

#1259
From: Robert Davies
Date: Wed, 16 Dec 1992 11:18
44 lines
1389 bytes
/*
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;
}
Technical Details
Message-ID: <BzCnEA.260@comp.vuw.ac.nz>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!comp.vuw.ac.nz!kauri.vuw.ac.nz!robertd

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!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