Topic: Borland, Microsoft and operator=()
Author: robertd@kauri.vuw.ac.nz (Robert Davies)
Date: Wed, 16 Dec 1992 11:18:10 GMT Raw View
/*
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;
}