发布时间:2013-01-04 10:53:17
#include "stdafx.h"#include <iostream>using namespace std; template <class T> void swap_pri(T& a, T& b){ T c; c=a; a=b; b=c;} int _tmain(int argc, _TCHAR* argv[]){ int a1 = 5; int b1 = 3; swap_pri(a1,b1); cout<< "a = "<<a1<......【阅读全文】
发布时间:2013-01-01 23:06:23
内联函数从源代码层看,有函数的结构,而在编译后,却不具备函数的性质。编译时,类似宏替换,使用函数体替换调用处的函数名。一般在代码中用inline修饰,但是能否形成内联函数,需要看编译器对该函数定义的具体处理。 #include "stdafx.h" #define swap1(a,b) {int c;c=a;a=b;b=c;}#define swap2(a,b) {a^=b,b^=a;a^=b;} inline void swap3(int &a,int &b);void swap3(int &a,int &b){&......【阅读全文】
发布时间:2013-01-01 20:50:23
#include "stdafx.h" #define swap1(a,b) {int c;c=a;a=b;b=c;}#define swap2(a,b) {a^=b,b^=a;a^=b;} int _tmain(int argc, _TCHAR* argv[]){ int a1=3; int b1=5; swap1(a1,b1); printf("a = %d, b= %d \n",a1,b1); int a2=3; int b2=5; swap2(a2,b2); &n......【阅读全文】