//操作符重载:
/******************************************************************************************
#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 阅读(464) 
评论(0)  编辑  收藏  所属分类: 
C++