using System; class space { int x, y, z; public space(int a, int b, int c) { x = a; y = b; z = c; } public void display() { Console.Write("" + x); Console.Write("" + y); Console.Write("" + z); } public static space operator -(space s) { s.x = -s.x; s.y = -s.y; s.z = -s.z; } } class TestMain { public static void Main() { space s = new space(10, -20, -40); Console.Write("S:"); -s.display(); Console.Write("S:"); Console.Write("S:"); -s.display(); } } it shows the following errors: Error 1 'space.operator -(space)': not all code paths return a value C:\Users\LENOVO PC\Documents\Visual Studio 2010\Projects\operator_overload\operator_overload\Program.cs 17 25 operator_overload Error 2 Only assignment, call, increment, decrement, and new object expressions can be used as a statement C:\Users\LENOVO PC\Documents\Visual Studio 2010\Projects\operator_overload\operator_overload\Program.cs 30 10 operator_overload Error 3 Operator '-' cannot be applied to operand of type 'void' C:\Users\LENOVO PC\Documents\Visual Studio 2010\Projects\operator_overload\operator_overload\Program.cs 33 10 operator_overload Error 4 Only assignment, call, increment, decrement, and new object expressions can be used as a statement C:\Users\LENOVO PC\Documents\Visual Studio 2010\Projects\operator_overload\operator_overload\Program.cs 33 10 operator_overload What I have tried: sir i have tried -s.display() but no results..
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)