Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
operator overriding
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class vector{ int a,b; public vector(){a=0;b=0;} public vector(int a,int b){this.a=a; this.b=b;} public static vector operator+(vector p1,vector p2) { vector p=new vector(); p.a=p1.a+p2.a; p.b=p1.b+p2.b; return p; } public static vector operator-(vector p1,vector p2) { vector p=new vector(); p.a=p1.a-p2.a; p.b=p1.b-p2.b; return p; } public static implicit operator int (vector v) { int ae; ae=v.a+v.b; return ae; } public static implicit operator vector (int v) { vector ae=new vector(); ae.a=v; ae.b=0; return ae; } public void display() { Console.WriteLine("the point are "+a+" " +b); } } public class Program { public static void Main(string[] args) { vector v1=new vector(1,2); vector v2=new vector(2,3); vector v3=new vector(); v3.display(); v3=v1+v2; v3.display(); v2.display(); int a; a=v3; Console.WriteLine(a); int b=10; vector v4=new vector(); v4=b; v4.display(); v3=v2-v1; v3.display(); } } }
run
|
edit
|
history
|
help
0
Random number + IF var change2
List Array
Write a program to count the occurrence of each distinct item in the array?
MultiThreading and CancellationToken
saxasd
Hello world
123
BNV
enigma
Pets Name Generator