Ŝablono (programado)

Ŝablono (angle template) estas unu el la manieroj, per kiuj estas realigata tiel nomata ĝenerala programado. La ŝablonoj haveblas en lingvoj C++, D (programlingvo), Java, C#, Eiffel, Haskell ktp.

Ŝablonoj ebligas i.a. kreadon de kodo sendependa de tipoj (do estas alternativo al la "macro"-funkcioj). Tio reduktas redundaĵojn de kodo.

Por uzi la ŝablonon necesas fari ĝian ekzemplon. Kreado de ekzemploj de ŝablonoj nomiĝas konkretigado.

La sintakso, kaj precipaj ecoj de ŝablonoj dependas de lingvo:

Ekzemplo

#include <iostream>

template<typename T>
T abs(T x)
{
    return x > 0 ? x : -x;
}

int main(void)
{
    std::cout << "Absoluta valoro de -5 : " << abs<int>(-5) << std::endl; // Entjera versio de la funkcio
    std::cout << "Absoluta valoro de 8.9f : " << abs<float>(8.9f) << std::endl; // Versio de la funkcio kun koma nombro
}

Vidu ankaŭ

Read other articles:

Halaman ini berisi artikel tentang istri Kaisar Nikolai I. Untuk Permaisuri Rusia yang dibunuh bersama keluarganya pada Revolusi Bolshevik, lihat Aleksandra Fyodorovna (istri Nikolai II). Aleksandra FyodorovnaАлекса́ндра ФёдоровнаLukisan Aleksandra oleh George Dawe, 1826.Permaisuri Kaisar RusiaPeriode1 Desember 1825 – 2 Maret 1855Penobatan3 September 1826Informasi pribadiKelahiranFriederike Luise Charlotte Wilhelmine(1798-07-13)13 Juli 1798Berlin, PrusiaKematian1 Novembe...

 

Bhimrao Ramji AmbedkarBhimrao Ramji Ambedkar en 1935.FonctionsMembre de la Rajya Sabha3 avril 1952 - 6 décembre 1956Ministre de la Justice d'Inde15 août 1947 - 6 octobre 1951Member of the Committee on Subjects Assigned to the Union Centre (d)1947-1950Member of the Negotiating Committee of the Constituent Assembly of India (d)1947-1950Member of the Advisory Committee of the Constituent Assembly of India (d)1947 - 24 janvier 1950Member of the Steering Committee of the Constituent Assembly of ...

 

Sporting event delegationTurkey at the1960 Summer OlympicsIOC codeTURNOCTurkish National Olympic CommitteeWebsiteolimpiyat.org.tr (in English and Turkish)in RomeCompetitors49 in 6 sportsFlag bearerNuri TuranMedalsRanked 6th Gold 7 Silver 2 Bronze 0 Total 9 Summer Olympics appearances (overview)190819121920192419281932193619481952195619601964196819721976198019841988199219962000200420082012201620202024Other related appearances1906 Intercalated Games Turkey competed at the 1960 Summer ...

Сибирский горный козёл Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКлада:АмниотыКлада:СинапсидыКла...

 

Philippine Benevolent Missionaries AssociationPhilippine Benevolent Missionaries Association, Inc.SealPBMA Divine Master's Shrine, Aurelio, San Jose, Dinagat Islands.Formation1965; 59 years ago (1965)FounderRuben Ecleo Sr.LocationSan Jose, Dinagat Islands, PhilippinesMembership (2013) 140,000 The Philippine Benevolent Missionaries Association, Inc. (PBMA) is a non-sectarian and non-profit charitable religious fraternal organization for men and women in the Philippines found...

 

Pemilihan umum Wali Kota Medan 20152010*20209 Desember 2015Kandidat   Calon Dzulmi Eldin Ramadhan Pohan Partai Partai Golongan Karya Demokrat Pendamping Akhyar Nasution Eddie Kusuma Suara rakyat 346.406 136.608 Persentase 71,72% 28,28% Peta persebaran suara Peta lokasi Medan Wali Kota petahanaDzulmi Eldin Partai Golongan Karya Wali Kota terpilih Dzulmi Eldin Partai Golongan Karya Pemilihan umum Wali Kota Medan 2015 dilaksanakan pada 9 Desember 2015 untuk memilih Wali kota dan Wakil...

Viswanathan AnandNama lengkapViswanathan AnandAsal negara IndiaGelarGrandmaster (1988)Juara Dunia2000-2002 (FIDE), 2007-2013 (undisputed)Rating FIDE2816 (Juli 2015) (No. 2 dalam FIDE World Rankings Juli 2015).Rating tertinggi2817 (Maret 2011) Viswanathan Anand (bahasa Tamil: விச்வநாதன் ஆனந்த்) (IPA: ʋiɕ'ʋəˌnɑˌt̪ʰən ɑnˌənd̪) (lahir 11 Desember 1969) adalah grandmaster catur India dan mantan juara dunia. Ia adalah satu ...

 

نظام الرعاية الصحية في كنيسة السبتيونمعلومات عامةالبلد  الولايات المتحدة[1] التأسيس 1973 النوع عمل تجاري المقر الرئيسي ألتامونت سبرنغز[1] موقع الويب adventhealth.com المنظومة الاقتصاديةالشركات التابعة Florida Hospital Foundation (en) Florida Hospital Medical Group (en) الصناعة health care industry (en) تعديل - ت...

 

American sociologist (born 1959) Tukufu ZuberiTukufu Zuberi (2010)BornAntonio McDaniel (1959-04-26) April 26, 1959 (age 65)Oakland, California, United StatesOccupationsociologist, professor, TV personality, social critic, documentary filmmaker, writer,NationalityAmericanAlma materSan Jose State (BA)Sacramento State (MA)University of Chicago (PhD)GenreSociology, filmmaking, historySubjectSociology, history, Africa Tukufu Zuberi (born April 26, 1959) is an American sociologist, filmma...

Women's keirin at the 2018 UEC European Track ChampionshipsVenueSir Chris Hoy Velodrome, GlasgowDate7 AugustCompetitors22 from 13 nationsMedalists  Mathilde Gros   France Nicky Degrendele   Belgium Daria Shmeleva   Russia← 20172019 → 2018 UEC EuropeanTrack ChampionshipsSprintmenwomenTeam sprintmenwomenTeam pursuitmenwomenKeirinmenwomenOmniummenwomenMadisonmenwomenTime trialmenwomenIndividual pursuitmenwome...

 

American board game designer Richard BorgBorn1948ConnecticutNationalityAmericanOccupationDesigner Part of a series onWargames Types Military wargaming Recreational wargaming Level of War Grand strategy wargame Strategic wargame Operational wargame Tactical wargame Skirmish Genres Air wargaming Board wargames Computer wargames Miniature wargaming Naval wargaming People 19th century pioneers Johann Hellwig Georg von Reisswitz Julius von Verdy du Vernois (1832–1910) Fred T. Jane (1865–1916) ...

 

Chess South AfricaSportChessJurisdictionSouth AfricaAbbreviationCHESS SAFounded1996AffiliationFIDELocationSouth AfricaPresidentAndre Lewaks[1]SponsorSASCOCOfficial websitechessa.co.za/index.aspx Chess South Africa (CHESS SA, previously CHESSA) is the national governing body for the sport of chess in South Africa. Chess South Africa is affiliated to the World Chess Federation (FIDE),[2] and to the African Chess Confederation (ACC). Chess South Africa administers the official n...

Indian actor (born 1982) Allari NareshAllari Naresh in February 2023BornEdara Naresh (1982-06-30) 30 June 1982 (age 42)Madras, Tamil Nadu, India(present-day Chennai)OccupationsActorFilm producerYears active2002–presentOrganizationE. V .V. CinemaSpouse Virupa Kantamneni ​(m. 2015)​Children1ParentE. V. V. Satyanarayana (father)RelativesAryan Rajesh (brother) Edara Naresh (born 30 June 1982), better known as Allari Naresh, is an Indian actor and film prod...

 

Letak Columbus di Ohio Columbus merupakan sebuah kota di Amerika Serikat. Kota ini letaknya di bagian tengah. Tepatnya di negara bagian Ohio. Pada tahun 2005, kota ini memiliki jumlah penduduk sebesar 754.885 jiwa dan memiliki luas wilayah 550,5 km². Kota ini memiliki angka kepadatan penduduk sebesar 1.373 jiwa/km². Pranala luar Wikivoyage memiliki panduan wisata Columbus. Situs resmi Diarsipkan 2006-05-10 di Wayback Machine. Experience Columbus Columbus Convention and Visitor Bureau C...

 

Apostle of the British Kingdom of Strathclyde Saint Kentigern alias MungoKentigern with a robin, a bell and a fish with a ring in its mouthBorn518 ADCulrossDied(614-01-13)13 January 614 (aged 95–96)Glasgow, Kingdom of StrathclydeVenerated in Roman Catholic Church Anglican Communion Presbyterian Church Eastern Orthodox Church Major shrineGlasgow CathedralFeast13 JanuaryAttributesBishop with a robin on his shoulder; holding a bell and a fish with a ring in its mouth[1]PatronageGl...

Cet article est une ébauche concernant le cyclisme et l’Espagne. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Tour d'Espagne 1968GénéralitésCourse 23e Tour d'EspagneCompétition Super Prestige Pernod 1968 (d)Étapes 18Date 25 avril - 12 mai 1968Distance 2 990 kmPays traversé(s) EspagneLieu de départ VigoLieu d'arrivée BilbaoÉquipes 9Coureurs au départ 90Coureurs à l'arrivée 51Vitesse mo...

 

National forest in Montana, United States Helena National ForestGates of the Mountains wilderness area, Helena National ForestLocationMontana, United StatesNearest cityHelena, MTCoordinates46°35′N 111°50′W / 46.583°N 111.833°W / 46.583; -111.833Area984,558 acres (3,984.36 km2)[1]EstablishedApril 12, 1906[2]Governing bodyU.S. Forest ServiceWebsiteHelena National Forest Helena National Forest is located in west-central Montana, in t...

 

Servi camerae regis (Latin: servants of the royal chamber, German: Kammerknechtschaft) was the status of the Jews in Christian Europe in the Middle Ages. The ruler had the right to tax them for the benefit of his treasury (camera regis), but at the same time he had a duty to protect them when they were in danger from others. The Laws of Edward the Confessor enacted in England in the 12th century defined the status of the Jews as follows: All Jews, wherever in the realm they are, must be under...

In the United States Navy, officers have various ranks. Equivalency between services is by pay grade. United States Navy commissioned officer ranks have two distinct sets of rank insignia: On dress uniform a series of stripes similar to Commonwealth naval ranks are worn; on service khaki, working uniforms (Navy Working Uniform [NWU], and coveralls), and special uniform situations (combat utilities, flight suits, and USMC uniforms when worn by Navy officers assigned or attached to USMC units)...

 

Chamber of the heart VentricleComputer generated animation of cut section of the human heart showing both ventricles.DetailsIdentifiersLatinventriculus cordisMeSHD006352TA98A12.1.00.012FMA7100Anatomical terminology[edit on Wikidata] A ventricle is one of two large chambers located toward the bottom of the heart that collect and expel blood towards the peripheral beds within the body and lungs. The blood pumped by a ventricle is supplied by an atrium, an adjacent chamber in the upper heart...