All pastes #232872 Raw Edit

Untitled

public text v1 · immutable
·published 2006-11-01 16:33 UTC
rendered paste body
class parent {
public:
   int asdf;
};

void negate(parent& p)
{
   p.asdf *= -1;
}

class A : public parent 
{
      A operator-() {
         A ret(*this);
         negate(ret);
         return ret;
      }
};

class B: public parent
{
      B operator-() {
         B ret(*this);
         negate(ret);
         return ret;
      }
};
 
int main(){
   A a;
   a.asdf = 2;
   A b = -a;
}