Click here to Skip to main content
15,917,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the below code give the error that "not all code path return value"
ublic static vector operator +(vector v1, vector v2)
{
vector v3 = new vector(((v1.X*v2.Y) +(v2.X*v1.Y)),(v1.Y*v2.Y));
Posted
Comments
Mehdi Gholam 29-Oct-11 1:50am    
Edit your question as it is incomplete.

actually i want to divide like this if 10/8 comes then i should divide this by 2 but how
 
Share this answer
 
Comments
Mehdi Gholam 29-Oct-11 1:50am    
Do not post solutions, edit your original question.
Solution is simple :

not all code path return value

You don't return anything in your method.

Look at the signature of the method :
public static vector operator +(vector v1, vector v2)


You have to return a vector from the method. Thus :

public static vector operator +(vector v1, vector v2)
{
   return new vector(v1.X * v2.Y + v2.X * v1.Y, v1.Y * v2.Y);
}


I suggest you get a good book on C# basis ; this is a fundamental field here that you seem to ignore.

Good luck.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900