写代码娱乐一下下:

//函数实现加法  http://write.blog.csdn.net/sunboyiris int add(int i,int j) { 	return i+j; }  //命名空间实现加法 http://write.blog.csdn.net/sunboyiris namespace fun1{ 	int add(int i,int j) 	{ 		return i+j; 	} } //模板实现加法 http://write.blog.csdn.net/sunboyiris template<typename T> T add1(T i1,T j1) { 	return i1+j1; } //类实现加法 http://write.blog.csdn.net/sunboyiris class class_add { public: 	int add2(int x,int y) 	{ 		return x+y; 	} }; //结构体实现加法 http://write.blog.csdn.net/sunboyiris struct struct_add { 	int add2(int x,int y) 	{ 		return x+y; 	} }; //内联汇编实现加法 http://write.blog.csdn.net/sunboyiris int add4(int x,int y){ int i1; 	_asm{ 	   mov eax ,x           add eax ,y 	   mov i1,eax } 	return i1; } //位运算实现加法 http://write.blog.csdn.net/sunboyiris int add3(int a, int b){  	int temp = 0;  	do{  		temp = a;  		a = a & b;  		b = b ^ temp;  		a = a << 1;  	}while(a != 0);   	return b;  } 

//调用形式如下: 	cout<<add(2,3)<<endl; 	cout<<fun1::add(2,4)<<endl;     cout<<add1(1.2,1.3)<<endl; 	cout<<a.add2(12,34)<<endl; 	cout<<b.add2(12,45)<<endl;     cout<<add4(12,35)<<endl;