2002

Grusel++ of the month

Home
Download Source
/******************************************************************************/
/*                                                                            */
/*                                                         FILE: december.cpp */
/*                                                                            */
/*  I am still surprised by some variants of misusing operators               */
/*  ===========================================================               */
/*                                                                            */
/*  Compiled and tested with Visual C++ V6.0                                  */
/*                                                                            */
/*  V1.01   27-DEC-2002   P. Tellenbach   http://www.heimetli.ch/             */
/*                                                                            */
/******************************************************************************/

#include <iostream>

struct X
{
   char *ps ;

   X &operator *()
   {
      std::cout.put( *ps++ ) ;

      return *this ;
   }

   int operator *( const X &x )
   {
      return 0 ;
   }
} x = { "Hello world !\n" } ;

int main()
{
   return * * * * * * * x * * * * * * * * x ;
}