日期:2014-05-16  浏览次数:20901 次

书上练习题:说是下面这段代码可以编译,就是不能像预期一样工作,让找出问题所在
书上练习题:说是下面这段代码可以编译,就是不能像预期一样工作,让找出问题所在:
namespace BuildingLibrary
{
    class PropertyLine
    {
        bool SharesEndpointWith(PropertyLine other)
        {
            XYZ startPoint = other.GetEndPoint(0);
            XYZ endPoint = other.GetEndPoint(1);

            return startPoint.ArePointsCoincident(m_startPoint) || 
                   endPoint.ArePointsCoincident(m_endPoint);
        }

        XYZ GetEndPoint(int index)
        {
            return (index == 0 ? m_startPoint : m_endPoint);
        }

        private XYZ m_startPoint;
        private XYZ m_endPoint;
    }

    class XYZ
    {
        public bool ArePointsCoincident(XYZ otherXYZ)
        {
            return (X == otherXYZ.X && Y == otherXYZ.Y && Z == otherXYZ.Z);
        }

        public double X
        {
            get { return m_X; }
        }

        public double Y
        {
            get { return m_Y; }
        }

        public double Z
        {
            get { return m_Z; }
        }

        private double m_X, m_Y, m_Z;
    }
}


看了半天没看出来,大家伙帮忙看看,不知道是哪儿有问题呀
------解决方案--------------------
 public bool ArePointsCoincident(XYZ otherXYZ)
        {
            return (X == otherXYZ.X && Y == otherXYZ.Y && Z == otherXYZ.Z);
        }
 
        public double X
        {
            get&n