作者GasolLee (嗨...)
看板C_Sharp
标题[问题] 关於运算子多载的问题
时间Sat Sep 24 07:48:03 2005
各位大大好
我写了一个小程式来练习C#运算子多载的功能
程式如下
using System;
public struct Point
{
public int x, y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
//以下省略节省版面
}
class A
{
public static void Main()
{
Point p1 = new Point(0, 0);
Point p2 = new Point(100, 10);
Point p3;
p3 = p1 + p2;
//p3 = p1+p2;
Console.WriteLine("p3.X = {0}, p3.Y = {1}", p3.X, p3.Y);
}
public static Point operator+(Point P1, Point P2)//, Point P2)
{
Point P;
P.x = 1;
P.y = 2;
return P1;
}
}
我在编译这个小程式的时候
一直出现以下的错误
One of the parameters of a binary operator must be the containing type
请问这是什麽意思呢???
请问我的这个小程式里面有哪里有错误的
因为我想了很久还是想不出来哪里有问题
请各位高手大大帮帮忙
教一下小弟我
谢谢噜~~~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.168.168.203