crash7.c

来自「this is a gcc file, you can download it 」· C语言 代码 · 共 49 行

C
49
字号
// Build don't link: // GROUPS passed templatestemplate<class T>class Vector{  int sz;  T *v;public:  Vector (int s) : sz (s) { v = new T[sz]; }  ~Vector () { delete[] v; }  T &operator[] (int i) { return v[i]; }  int size () { return sz; }};template<class T>// ERROR - previous definition of Tstruct Comparator{  typedef T T;// ERROR - use of template type T in typedef to T  static int lessthan (T &a, T &b) { return a < b; }};template<class Comp>struct Sort{  static void sort (Vector<Comp::T> &);// ERROR - use of bad T};template<class Comp>void Sort<Comp>::sort (Vector<Comp::T> &v)// ERROR - use of bad T{  int n = v.size ();  for (int i = 0; i < n - 1; i++)    for (int j = n - 1; i < j; j--)      if (Comp::lessthan (v[j], v[j - 1]))	{	  typename Comp::T temp = v[j];	  v[j] = v[j - 1];	  v[j - 1] = temp;	}}voidf (Vector<int> &vi){  Sort<Comparator<int> >::sort (vi);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?