啪啪拉拉噼里啪啦

          初學者天堂資料匯集

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            16 隨筆 :: 73 文章 :: 16 評論 :: 0 Trackbacks
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          公告

          本人聯系信箱bigdachun@126.com bigdachun@gmail.com
          月 [下月] [上月]
          1234567
          891011121314
          15161718192021
          22232425262728
          2930

          QQ:站長qq在線狀態

          常用鏈接

          留言簿(3)

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          時鐘

          留言

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          #include<iostream.h>
          #include<math.h>

          class Point
          { public:
          Point(int xx=0,int yy=0) {X=xx;Y=yy;} //構造函數的定義
          Point(Point &P);                      //拷貝構造函數定義
          int GetX() {return X;}                //得到X的值。
          int GetY() {return Y;}                //得到Y的值
          private:
           int X,Y;

          };
          Point :: Point(Point &P)  //拷貝構造函數的實現
          {  X=P.X;
             Y=P.Y;
           cout<<"point拷貝構造函數的調用"<<endl;
           cout<<"Point"<<endl;
          }
          //類的組合
          class Distance
          { public:
               Distance(Point XP1,Point XP2);
            double GetDis(){return Dist;}
          private:
            Point P1,P2;
            double Dist;
            double x,y;
          };
          //組合類的構造函數
          Distance::Distance(Point XP1,Point XP2):P1(XP1),P2(XP2)
          { cout<<"Distance 構造函數調用"<<endl;
             x=double(P1.GetX()-P2.GetX());
             y=double(P1.GetY()-P2.GetY());
            Dist=sqrt(x*x+y*y);
          }

          void main()
          { Point myp1(1,1), myp2(4.5);
            Distance myd(myp1,myp2);
            cout<<"the distance is"<<endl;
            cout<<myd.GetDis()<<endl;
           
          }

          posted on 2005-04-03 17:27 噼里啪啦的世界 閱讀(186) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 湘阴县| 宁晋县| 澳门| 甘洛县| 博客| 蓝山县| 屏东市| 远安县| 开化县| 雅安市| 博客| 张家港市| 阳东县| 堆龙德庆县| 丹巴县| 安宁市| 蒲城县| 宜兰市| 太和县| 佛山市| 武冈市| 福州市| 忻州市| 陵水| 仁怀市| 光山县| 武邑县| 鲁甸县| 嵊州市| 尉犁县| 新宁县| 拜城县| 芜湖县| 于田县| 仙游县| 揭西县| 赤城县| 孝感市| 大荔县| 手游| 阳泉市|