🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Robert Davies Wed, 16 Dec 1992 11:18
Borland, Microsoft and operator=()
#1259
Author: 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;
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads