I have come across some code that compiles with Visual C++ 6.0 (98) but not with g++ (various versions on linux, cygwin and solaris).


The first issue has to do with passing the return value of one function into another by reference. This code does not compile with g++ 3.3.1 or 2.9x. Download the file ObjectRef.cpp


The second issue has to do with how a friend class is specified. This code does compile on a linux box in cs with g++ 2.96. It also does compile on a solaris host with g++ 2.95.3. It does not compile under cygwin on my personal machine (3.3.1) nor on my personal linux machine (also 3.3.1). Download the file Friend.cpp.


With G++ I try to compile with the following command:


I get the following error results:


With MSVC I try to compile with the following command:


I get the following successful results: