classes and operators

Hi, I need help with classes and operators. I'm trying to make a class that is used as a data structure because I need a variable that holds more decimal places than a double or a float. This structure is going to be multiplied in an equation later.

I know that I have to define what the multiplication operator does, and so I am supposed to overload the operator.

Let's call my data structure a "Fan".
I have:

1
2
3
4
fan operator * ()
{
  return result;
}


I am completely lost on what else I'm supposed to put in this function.

Please help!
I'm trying to make a class that is used as a data structure because I need a variable that holds more decimal places than a double or a float.

You do know about Gnu MP, right?

I am completely lost on what else I'm supposed to put in this function.

Well, you at least need an right-side operand:
1
2
3
4
5
6
fan operator * (const fan& rhs) const
{
  fan result(*this);
  //multiply result with rhs
  return result;
}
Last edited on
You do know about Gnu MP, right?


No, I have not heard of it, why?
Topic archived. No new replies allowed.