随笔分类 - c\c++
操作符重载
摘要:#include <iostream>using namespace std;typedef void(*FUNC)(void);void a(){ cout << "This is a func ! \n";}void b(){ cout << "This is b func ! \n";}class c{public: void operator()(void) { cout << "This is a class c!\n"; }};template<class T>c
阅读全文
模板与特化
摘要:1 #include <iostream> 2 3 using namespace std; 4 5 template <typename T> 6 void AnySwap(T &a, T &b) 7 { 8 T temp = a; 9 a = b;10 b = temp;11 }12 //重载13 template <typename T>14 void AnySwap(T a[], T b[], int n)15 {16 T temp;17 for(int i = 0; i < n; i++)18 {19 temp = a[i];
阅读全文
预处理、宏定义
摘要:View Code #include <stdio.h>#define MAX(x,y) (x>y?x:y)#define PRINT_INT(x) printf(#x" %d\n",x)#define PRINT_F(x) printf(#x" %f\n",x)#define PRINT_HELLO() \ printf("Hello, World\n")#define GENERIC_MAX(type) \ type type##_max(type x,type y) \ { \ return x>y...
阅读全文
浙公网安备 33010602011771号