Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. // .cpp
  2.  
  3.     template<typename T>
  4.     Hospital<T>::Hospital () {
  5.         #ifdef MY_DEBUG
  6.             clog << D_PREFIX "Hospital constructor called!" << endl;
  7.         #endif
  8.         h = new Hospital::HospitalPrivate();
  9.     }
  10.  
  11.     template<typename T>
  12.     void Hospital<T>::sortPatients (T Sort) {
  13.         int i;
  14.         i = h->patient.size();
  15.         if (i < 2) {
  16.             return;
  17.         } else {
  18.                 for (int k = 0; k < i-1; k++) {
  19.                     for (int j = 0; j < i - 2; j++) {
  20.                         if ( Sort(*h->patient[j], *h->patient[j+1] )) {
  21.                             swap(h->patient.at(j), h->patient.at(j+1));
  22.                         }
  23.                     }
  24.                 }
  25.         }
  26.     }
  27.  
  28.  
  29. // main.cpp
  30.   Hospital<CompareFunc<Patient>> hospital;
  31.   hospital.sortPatients(CompareFunc<Patient>());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement