templates_examples_1onPage

templates_examples_1onPage - : swap >template

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
היצקנופה Swap סופיט לכל הבוט T , הקתעה יאנב םירדגומ ורובעש רוטרפואו = לשמל : המגוד : היצקנופ swap template < typename T> void { T temp = a; a = b; b = temp; } הקתעה יאנב רוטרפוא = String s1, s2; Swap(s1,s2); int x = 5, y = 10; Swap(x,y);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ךרעמ תקתעהל היצקנופ : המגוד : תויצקנופ template םיכרעמל template < class T> void CopyArray(T a[], T b[], size_t size) { for ( int i=0; i < size; ++i) a[i] = b[i]; } רוטרפוא = ךרעמ תספדהל היצקנופ : template < class T> void PrintArray(T *a, size_t n) { for ( int i = 0; i < n; ++i) cout << a[i] << endl; cout<< "\n" ; } רוטרפוא >>
Background image of page 2
המגוד : תיצקנופ quicksort template < class Comparable> void quicksort(Comparable a[], int left, int right){ if (left >= right) // array contains less than 2 elements return ; int last = left; for ( int i = left+1; i <= right; ++i) if (a[i] < a[left])
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/14/2011 for the course CS 234122 taught by Professor Gillbarequet during the Spring '11 term at Technion.

Page1 / 4

templates_examples_1onPage - : swap >template

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online