//操作符重載:
          /******************************************************************************************
          #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的實(shí)現(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 閱讀(447) 評論(0)  編輯  收藏 所屬分類: C++

          常用鏈接

          留言簿(21)

          隨筆分類(265)

          隨筆檔案(242)

          相冊

          JAVA網(wǎng)站

          關(guān)注的Blog

          搜索

          •  

          積分與排名

          • 積分 - 914959
          • 排名 - 40

          最新評論

          主站蜘蛛池模板: 岳西县| 和田市| 黄龙县| 清苑县| 谢通门县| 花莲县| 七台河市| 海安县| 定结县| 澄城县| 延川县| 临颍县| 河南省| 江油市| 阳朔县| 清丰县| 呼和浩特市| 天祝| 镇远县| 秭归县| 旬邑县| 瑞昌市| 屯留县| 宜兰市| 全南县| 阜康市| 沂源县| 扎囊县| 花莲县| 奉化市| 上高县| 南岸区| 华亭县| 博湖县| 泰宁县| 衡阳县| 屏南县| 荆州市| 兴化市| 特克斯县| 体育|