check it out:

class Fraction
{
private:
  int num, den;
public:
  Fraction() : num(1), den(1) { }

  // overloading the () operator for the Fraction object.
  // you can pass parameters, or return a type from this func as well
  void operator()( void )
  {
    printf("operator().\n");
    printf("I'm what happens when you invoke this object AS a function\n");
    printf("Can you think of some really cool uses for me???  I think you can.");
  }
};

int main()
{
  Fraction f;
  f();    // invoke the Fraction object. . . NEATO!!!  
  return 0;
}

Post a Comment