Operatörlerin Aşırı Yüklenmesi

using System;
using System.Collections.Generic;
using System.Text;

namespace operatorlerin_asiri_yuklenmesi
{
class Program
{
static void Main(string[] args)
{

x r1 = new x(60,20);
x r2 = new x(20,30);
r1.yaz();
r2.yaz();
x r3;
r3 = r1 + r2;
r3.yaz();
}
}

class x {

private int k1, k2;
public x(int m, int n) {

k1 = m;
k2 = n;

}
static public x operator +(x a, x b) {
x temp = new x(0, 0);
temp.k1 = a.k1 + b.k2;
return temp;
}
public void yaz() {

Console.WriteLine(” k1:” + k1 + ” k2:” + k2);
}
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s