I am writing a class to deal with complex numbers.
First of all, is it possible to overload "**" as an operator? I played around with it a lot, but it doesn't look like it's gonna let me do it.
If that doesn't work, I would like to have a function pow(Complex,int) that will raise 'Complex' to the power 'int'. I have it working o.k., but to use it in a main program, I have do use do something like:
Code:
Complex access, a(2,4);
Complex b = access.pow(a,2);
I am thinking that you can get around this with friend functions, but I can't seem to get the declerations right. Here's what I have:
Code:
class Complex
{
public:
friend Complex pow(Complex, int);
}
Complex Complex::pow(Complex number,int power)
{ ..... }
Is there a way to do this so that I can use the pow(Complex,int) function without calling it as a member function?
EDIT:
crap, nevermind....
Code:
Complex pow(Complex number,int power)