//操作符重載:
          /******************************************************************************************
          #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的實現(xiàn)吧:)
          {
          }

          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 閱讀(443) 評論(0)  編輯  收藏 所屬分類: C++

          常用鏈接

          留言簿(21)

          隨筆分類(265)

          隨筆檔案(242)

          相冊

          JAVA網(wǎng)站

          關(guān)注的Blog

          搜索

          •  

          積分與排名

          • 積分 - 914107
          • 排名 - 40

          最新評論

          主站蜘蛛池模板: 万载县| 婺源县| 蒙阴县| 黑龙江省| 溧阳市| 紫阳县| 漳浦县| 隆尧县| 濮阳县| 博乐市| 宣恩县| 盐池县| 南京市| 旺苍县| 吴桥县| 通渭县| 军事| 安图县| 阿鲁科尔沁旗| 法库县| 正蓝旗| 浦北县| 隆回县| 蕲春县| 安化县| 商丘市| 阿巴嘎旗| 化隆| 乐昌市| 周宁县| 河东区| 南充市| 南安市| 崇礼县| 黔西县| 漠河县| 那坡县| 琼结县| 穆棱市| 龙泉市| 汝阳县|