//操作符重載:
          /******************************************************************************************
          #include "stdafx.h"
          #include <string>
          #include <fstream>
          #include <iostream>
          #include <algorithm>
          #include <map>
          #include <vector>

          using namespace std;
          class arry
          {
          ?public:
          ??arry(int x[2][2])
          ??{
          ???for(int i=0;i<2;i++)
          ???{
          ????for(int j=0;j<2;j++)
          ????{
          ?????arr[i][j]=x[i][j];
          ????}
          ???}
          ??}
          ??arry operator+(arry b);
          ??void display();
          ?private:
          ??int arr[2][2];

          };
          arry arry::operator+(arry b)
          {
          ?int c[2][2];
          ?for(int i=0;i<2;i++)
          ?{
          ??for(int j=0;j<2;j++)
          ??{
          ???c[i][j]=arr[i][j]+b.arr[i][j];
          ??}
          ?}
          ?return arry(c);
          }

          void arry::display()//自己寫display的實現吧:)
          {
          }

          int main(int argc,_TCHAR* argv[])
          {
          ?int a1[2][2]={1,2,3,4},b1[2][2]={1,2,3,4},c1[2][2]; //注意這兩行的修改
          ?arry a(a1),b=(b1),c(c1); //注意這兩行的修改
          ?cout<<"a=";a.display();
          ?cout<<"b=";b.display();
          ?c=a+b;
          ?cout<<"c=a+b=";
          ?c.display();
          }

          posted on 2008-04-08 23:48 -274°C 閱讀(453) 評論(0)  編輯  收藏 所屬分類: C++

          常用鏈接

          留言簿(21)

          隨筆分類(265)

          隨筆檔案(242)

          相冊

          JAVA網站

          關注的Blog

          搜索

          •  

          積分與排名

          • 積分 - 916109
          • 排名 - 40

          最新評論

          主站蜘蛛池模板: 周至县| 内江市| 赣州市| 黑河市| 分宜县| 西城区| 绥滨县| 绥江县| 新绛县| 铜鼓县| 茶陵县| 永和县| 金乡县| 河东区| 沁阳市| 林芝县| 松原市| 鲁山县| 吐鲁番市| 磴口县| 彰武县| 黑河市| 门源| 沙田区| 定日县| 惠州市| 金坛市| 手游| 海原县| 南部县| 正定县| 泽库县| 新安县| 福海县| 高唐县| 桃园县| 平潭县| 乌苏市| 孟村| 庆安县| 黑河市|