1

Im overloading the Double Parentheses function and using it inside the same class for a matrix in c++? Im confident I overloaded it properly but I do not know how to call it from inside itself.

Christoph
  • 1,965
  • 16
  • 35
Doug B
  • 175
  • 1
  • 1
  • 7

1 Answers1

2

I'm assuming that your Double Parentheses function is operator(), then you can call it from inside other member functions in two different ways:

    unsigned operator()(unsigned i) const
    {
        if(i == 0) return 1;
        return operator()(i-1);
    }

or

    unsigned operator()(unsigned i) const
    {
        if(i == 0) return 1;
        return (*this)(i-1);
    }
SirGuy
  • 10,660
  • 2
  • 36
  • 66