i am trying to write a program to overload the ^ operator. so far when i compile it i have two of the same errors on lines 10 and 17. The compiler is telling me that the struct, class, or interface must have a return type. I thought that I was returning in in line 40 but there is some other mistake that I am not catching.
here is the code!?
CODE
using System;
class power
{
public int x;//, y, z;
public Vector(int x)//, int y, int z);
{
this.x = x;
//this.y = y;
//this.z = z;
}
public Vector(Vector rhs)
{
x = rhs.x;
//y = rhs.y;
//z = rhs.z;
}
public override string ToString()
{
return "( " + x + " )";//, " + y + ", " + z + " )";
}
public static Vector operator ^ (Vector lhs, Vector rhs)
{
Vector result = new Vector(lhs);
result.x = rhs.x * rhs.x * rhs.x;
//result.y = rhs.y * rhs.y * rhs.y;
//result.z = rhs.z * rhs.z * rhs.z;
return result;
}
public static Vector operator ^ (Vector lhs, Vector rhs)
{
return new Vector(lhs * rhs.x);
}
} //END CLASS POWER
class RaisePower
{
public static void Main(string[] args)
{
Vector vect1;
vect1 = new Vector(3.0);
Console.WriteLine("vect1 = " + vect1.ToString());
}
}