{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cap7 - Cap 7 Template-uri Template-ul implementeaza...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Cap. 7. Template-uri Template-ul implementeaza asa-zisul concept de " tip parametrizat " (" parametrized type "). Un template reprezinta o familie de tipuri sau functii, cu alte cuvinte, un sablon sau model. Acest concept a fost introdus in primul rand pentru a creste gradul de reutilizabilitate a codului. De exemplu, pentru a implementa o lista de numere intregi este necesara in mod normal realizarea unei clase speciale (sa spunem ListOfIntegers ), iar pentru o lista de siruri alta clasa (sa spunem ListOfStrings ). Conceptul de template permite realizarea unei clase generale (sa spunem List ), care sa accepte orice tip de element, inclusiv tipuri necunoscute la momentul implementarii acesteia. Tipul template-ului este stabilit in momentul instantierii sale. Template-urile sunt foarte utile pentru realizarea de biblioteci care trebuie sa ofere metode generice de prelucrare a datelor. Sintaxa generala de declarare a unui template este urmatoarea: template < ListaDeParametri > Declaratie unde Declaratie reprezinta declararea sau definirea unei clase sau functii, definirea unui membru static al unei clase template, definirea unei clase sau functii membre al unei clase template, sau definirea unui membru template al unei clase.
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern