C++: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
pembenahan |
+wkf, penambahan redaksi Tag: halaman dengan galat kutipan VisualEditor |
||
(200 revisi antara oleh lebih dari 100 100 pengguna tak ditampilkan) | |||
Baris 1:
{{Infobox programming language
| name = C++
| logo = File:ISO C++ Logo.svg
| logo caption = Logo didukung oleh Standar C++
| logo size = 120px
| paradigms = [[Bahasa pemrograman multiparadigma|Multi-paradigma]]: [[pemrograman prosedural|prosedural]], [[pemrograman fungsional|fungsional]], [[pemrograman berorientasi objek|orientasi objek]], [[pemrograman generik|generik]], [[Pemrograman modular|modular]]
| family = [[C (bahasa pemrograman)|C]]
| designer = [[Bjarne Stroustrup]]
| developer = [[ISO/IEC JTC 1/SC 22|ISO/IEC JTC 1 (Joint Technical Committee 1) / SC 22 (Subcommittee 22)]] / WG 21 (Working Group 21)
| released = {{Start date and age|df=yes|1985}}
| latest release version = [[C++20]] {{Small|(ISO/IEC 14882:2020)}}
| latest release date = {{Start date and age|2020|12|15|df=yes}}
| latest preview version = [[C++23]]
| latest preview date = {{Start date and age|2022|3|17|df=yes}}
| typing = [[Tipe statis|Statis]], [[Sistem tipe nominal|nominal]], [[Interfrensi jenis|sebagian interfrensi]]
| scope =
| platform =
| operating system = [[lintas platform]]
| file ext = .C, .cc, .cpp, .cxx, {{nowrap|.c++}}, .h, .H, .hh, .hpp, .hxx, {{nowrap|.h++}}
| file format =
| implementations = {{nowraplinks| [[GNU Compiler Collection|GCC]], [[Clang|LLVM Clang]], [[Microsoft Visual C++]], [[C++Builder|Embarcadero C++Builder]], [[Intel C++ Compiler]], [[IBM XL C++]], [[Edison Design Group|EDG]]}}
| dialects =
| wikibooks = C++ Programming
| influenced by = [[Ada (bahasa pemrograman)|Ada]], [[ALGOL 68]],<ref name="history-cpp-paper">{{cite encyclopedia |last=Stroustrup |first=Bjarne |date=1996 |pages=699–769 |title=A history of C++: 1979-1991 |work=History of programming languages---II |publisher=[[Association for Computing Machinery|ACM]] |doi=10.1145/234286.1057836}}</ref> [[BCPL]],<ref name="cppcon21_bj">{{cite web |url=https://www.youtube.com/watch?v=15QF2q66NhU |title=C++20: Reaching for the Aims of C++ - Bjarne Stroustrup - CppCon 2021 |first=Bjarne |last=Stroustrup |publisher=CppCon |date=December 16, 2021}}</ref> [[C (bahasa pemrograman)|C]], [[CLU (bahasa pemrograman)|CLU]],<ref name="history-cpp-paper" /> [[ML (bahasa pemrograman)|ML]], [[Mesa (bahasa pemrograman)|Mesa]],<ref name="history-cpp-paper" /> [[Modula-2]],<ref name="history-cpp-paper" /> [[Simula]], [[Smalltalk]]<ref name="history-cpp-paper" />
| influenced = [[Ada (bahasa pemrograman)|Ada 95]]<!-- 1995 -->, [[C Sharp (bahasa pemrograman)|C#]]<!-- 2001 -->,<ref name="influenceSharp">{{cite journal |last=Naugler |first=David |date=May 2007 |title=C# 2.0 for C++ and Java programmer: conference workshop |journal=Journal of Computing Sciences in Colleges |volume=22 |issue=5 |quote=Although C# has been strongly influenced by Java it has also been strongly influenced by C++ and is best viewed as a descendant of both C++ and Java.}}</ref> [[C99]]<!-- 1999 -->, [[Carbon (bahasa pemrograman)|Carbon]], [[Chapel (bahasa pemrograman)|Chapel]],<ref name="chplspec">{{cite web|title=Chapel spec (Acknowledgements)|url=https://chapel-lang.org/spec/spec-0.98.pdf|date=1 October 2015|access-date=14 January 2016|publisher=Cray Inc|archive-date=24 June 2018|archive-url=https://web.archive.org/web/20180624150422/https://chapel-lang.org/spec/spec-0.98.pdf|url-status=live}}</ref> [[Clojure]],<ref>{{cite web |url=http://www.codequarterly.com/2011/rich-hickey/ |archive-url=https://web.archive.org/web/20170111184835/http://www.codequarterly.com/2011/rich-hickey/ |url-status=dead |archive-date=2017-01-11 |title=Rich Hickey Q&A by Michael Fogus |access-date=2017-01-11}}</ref> [[D (bahasa pemrograman)|D]]<!-- 1999 -->, [[Java (bahasa pemrograman)|Java]]<!-- 1995 -->,<ref>{{cite web |url=https://books.google.com/books?id=0rUtBAAAQBAJ&pg=PA133 |title=Cracking The Java Programming Interview :: 2000+ Java Interview Que/Ans |author=Harry. H. Chaudhary |access-date=29 May 2016 |date=28 July 2014 |archive-date=27 May 2021 |archive-url=https://web.archive.org/web/20210527025512/https://books.google.com/books?id=0rUtBAAAQBAJ&pg=PA133 |url-status=live }}</ref> [[JS++]],<ref>{{cite web|url=https://www.onux.com/jspp/blog/scaling-jspp-abstraction-performance-and-readability/|title=Scaling JS++: Abstraction, Performance, and Readability|author=Roger Poon|date=1 May 2017|access-date=21 April 2020|archive-date=11 May 2020|archive-url=https://web.archive.org/web/20200511095442/https://www.onux.com/jspp/blog/scaling-jspp-abstraction-performance-and-readability/|url-status=live}}</ref> [[Lua (bahasa pemrograman)|Lua]]<!-- 1993 -->, [[Nim (bahasa pemrograman)|Nim]],<ref>{{cite web|url=https://nim-lang.org/faq.html|title=FAQ Nim Programming Language|access-date=2020-04-21|archive-date=11 July 2017|archive-url=https://web.archive.org/web/20170711004631/https://nim-lang.org/faq.html|url-status=live}}</ref> [[Objective-C++]], [[Perl]]<!-- 1987 -->, [[PHP]]<!-- 1995 -->, [[Python (bahasa pemrograman)|Python]],<ref>{{Cite web|url=https://docs.python.org/tutorial/classes.html|title=9. Classes — Python 3.6.4 documentation|website=docs.python.org|access-date=2018-01-09|archive-date=23 October 2012|archive-url=https://web.archive.org/web/20121023030209/http://docs.python.org/tutorial/classes.html|url-status=live}}</ref> [[Rust (bahasa pemrograman)|Rust]], [[Seed7]]
}}
'''C++''' (dibaca: '''C plus-plus''') adalah [[bahasa pemrograman]] [[komputer]] yang dibuat oleh [[Bjarne Stroustrup]], yang merupakan perkembangan dari bahasa C dikembangkan di [[Bell Labs]] ([[Dennis Ritchie]]). Pada awal tahun 1970-an, bahasa itu merupakan peningkatan dari bahasa sebelumnya, yaitu [[B (bahasa pemrograman)|B]].
Pada awalnya, bahasa tersebut dirancang sebagai bahasa pemrograman yang dijalankan pada sistem [[Unix]]. Pada perkembangannya, versi ANSI (American National Standards Institute) pada [[bahasa pemrograman C]] menjadi versi dominan, meskipun versi tersebut sekarang jarang dipakai dalam pengembangan sistem dan jaringan maupun untuk sistem ''embedded''. Dengan demikian, bahasa C++ dapat dikategorikan sebagai [[bahasa pemrograman tujuan umum]] (''general-purpose programming language''; GPL)
Bjarne Stroustrup pada Bell Labs pertama kali mengembangkan C++ pada awal [[1980]]-an. Untuk mendukung fitur-fitur pada C++, dibangun efisiensi dan sistem support untuk pemrograman tingkat rendah (''low level coding'').<ref>{{cite book
|last = Hanif al fatta
|title = Dasar Pemrograman C++ disertai dengan Pengenalan Pemrograman Berorientasi Objek
|year = 2006
|isbn = 979-763-582-1}}</ref> Pada C++ ditambahkan konsep-konsep baru seperti class dengan sifat-sifatnya seperti inheritance dan overloading.<ref>{{Cite book|last=Al Fatta|first=Hanif|date=2006|url=https://www.google.co.id/books/edition/Dasar_Pemrograman_C++_Disertai_dengan_Pe/H20EMvS2EmQC?hl=id&gbpv=1&dq=Pada+C%2B%2B+ditambahkan+konsep-konsep+baru+seperti+class+dengan+sifat-sifatnya+seperti+inheritance+dan+overloading&pg=PA1&printsec=frontcover|title=Dasar Pemograman C++ Disertai Dengan Pengenalan Pemograman Berorientasi Objek|location=Yogyakarta|publisher=CV. Andi Offset|isbn=979-763-582-1|editor-last=Triyuliana|editor-first=Agnes Heni|pages=1|url-status=live}}</ref> Salah satu perbedaan yang paling mendasar dengan bahasa C adalah dukungan terhadap konsep [[pemrograman berorientasi objek]] (''object-oriented programming'').<ref>{{cite book
|last = Bruce Eckel
|title = Thinking in C++. Jilid 1 dari Thinking in C++ Introduction to Standard C+, Bruce Eckel
|year = 2000
|isbn = 0139798099, 9780139798092}}</ref><ref>{{cite book
|last = Bjarne Stroustrup
|title = The C++ programming language, Prentice Hall, 2000
|year = 2000
|isbn = 0201889544, 9780201889543}}</ref>
== Sejarah ==
[[Berkas:BjarneStroustrup.jpg|jmpl|Bjarne Stroustrup, pembuat dari C++, di kantor AT&T-nya di New Jersey c. 2000]]
Pada 1979, [[Bjarne Stroustrup]], seorang [[ilmuan komputer]] Denmark, memulai pekerjaan pada "{{visible anchor|C dengan [[Kelas (ilmu komputer)|Kelas]]}}", pendahulunya C++.<ref name="invention32">{{cite web|last=Stroustrup|first=Bjarne|date=7 March 2010|title=Bjarne Stroustrup's FAQ: When was C++ invented?|url=http://www.stroustrup.com/bs_faq.html#invention|website=stroustrup.com|archive-url=https://web.archive.org/web/20160206214150/http://www.stroustrup.com/bs_faq.html#invention|archive-date=6 February 2016|access-date=16 September 2010|url-status=live}}</ref> Motivasi untuk membuat bahasa pemrograman baru originated dari pengalaman Stroustrup dalam pemrograman untuk tesis PhD-nya. Stroustrup menemukan bahwa [[Simula]] mempunyai fitur yang sangat membantu untuk pengembangan perangkat lunak besar, tapi bahasanya terlalu lambat untuk penggunaan praktis, sementara [[BCPL]] cepat tapi levelnya terlalu rendah agar cocok untuk pengembangan perangkat lunak besar. Saat Stroustrup mulai bekerja pada [[Bell Laboratories|AT&T Bell Labs]], dia mempunyai masalah menganalisi [[Kernel (ilmu komputer)|kernel]] [[Unix|UNIX]] sehubungan dengan [[komputasi terdistribusi]]. Mengingat pengalaman PhD-nya, Stroustrup bertindak untuk meningkatkan bahasa [[C (bahasa pemrograman)|C]] dengan fitur seperti [[Simula]].<ref name="evolving">{{cite web|last=Stroustrup|first=Bjarne|title=Evolving a language in and for the real world: C++ 1991-2006|url=http://stroustrup.com/hopl-almost-final.pdf|archive-url=https://web.archive.org/web/20071120015600/http://www.research.att.com/~bs/hopl-almost-final.pdf|archive-date=20 November 2007|access-date=14 August 2013|url-status=live}}</ref>
=== Etimologi ===
Menurut Stroustrup, "namanya menandakan sifat evolusioner dari perubahan dari C".<ref name="name">{{cite web|title=Bjarne Stroustrup's FAQ – Where did the name "C++" come from?|url=http://www.stroustrup.com/bs_faq.html#name|archive-url=https://web.archive.org/web/20160206214150/http://www.stroustrup.com/bs_faq.html#name|archive-date=6 February 2016|access-date=16 January 2008|url-status=live}}</ref> Nama ini dikreditkan ke Rick Mascitti (pertenngahan-1983)<ref name="hopl2" /> dan digunakan pertama kali pada Desember 1983. Ketika Mascitti ditanyai secara informal pada tahun 1992 tentang penamaan, dia menunjukkan bahwa itu diberikan dalam semangat [[Tongue-in-cheek]]. Nama itu berasal dari [[Operator (pemrograman komputer)|operator]] [[C (bahasa pemrograman)|C]] <syntaxhighlight lang="C++" inline="">++</syntaxhighlight> (yang [[Operator penambahan dan pengurangan|menambah]] [[Nilai (ilmu komputer)|nilai]] dari sebuah [[Variabel (matematika)|variabel]]) dan [[konvensi penamaan]] umum menggunakan "+" untuk mengindikasikan sebuah program komputer yang disempurnakan.
Selama pengembangan periode C++, bahasa ini disebut sebagai "new C" dan "C dengan kelas"<ref name="hopl22" /><ref>{{cite web|title=C For C++ Programmers|url=https://www.ccs.neu.edu/course/com3620/parent/C-for-Java-C++/c-for-c++-alt.html|publisher=[[Northeastern University]]|archive-url=https://web.archive.org/web/20101117003419/http://www.ccs.neu.edu/course/com3620/parent/C-for-Java-C++/c-for-c++-alt.html|archive-date=17 November 2010|access-date=7 September 2015|url-status=dead|df=dmy-all}}</ref> sebelum mendapat nama akhir.
=== Standardisasi ===
{| class="wikitable floatright" style="margin-left: 1.5em;"
|+Standar C++
|-
!scope="col"| Tahun
!scope="col"| Standar C++<ref name="cppreference">{{cite web |url=http://en.cppreference.com/w/cpp/language/history |title=History of C++ |website=en.cppreference.com |access-date=March 16, 2022 |archive-date=Feb 2, 2022 |archive-url=https://web.archive.org/web/20220202052857/http://en.cppreference.com/w/cpp/language/history |url-status=live }}</ref>
!scope="col"| Nama informal
|-
!scope="row"| 1998
| | ISO/IEC 14882:1998<ref name="isocpp1998">{{cite web|title=ISO/IEC 14882:1998|publisher=International Organization for Standardization|url=https://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=25845|access-date=23 November 2018|archive-date=15 January 2017|archive-url=https://web.archive.org/web/20170115080045/http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=25845|url-status=live}}</ref> || C++98
|-
!scope="row"| 2003
| | ISO/IEC 14882:2003<ref name="isocpp2003">{{cite web|title=ISO/IEC 14882:2003|publisher=International Organization for Standardization|url=https://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=38110|access-date=23 November 2018|archive-date=13 August 2021|archive-url=https://web.archive.org/web/20210813193332/https://www.iso.org/standard/38110.html|url-status=live}}</ref> || [[C++03]]
|-
!scope="row"| 2011
| | ISO/IEC 14882:2011<ref name="isocpp2011">{{cite web|title=ISO/IEC 14882:2011|publisher=International Organization for Standardization|url=https://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=50372|access-date=23 November 2018|archive-date=27 May 2016|archive-url=https://web.archive.org/web/20160527084921/http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?ics1=35&ics2=60&ics3=&csnumber=50372|url-status=live}}</ref> || [[C++11]], C++0x
|-
!scope="row"| 2014
| | ISO/IEC 14882:2014<ref name="isocpp2014">{{cite web|title=ISO/IEC 14882:2014|publisher=International Organization for Standardization|url=https://www.iso.org/iso/home/store/catalogue_ics/catalogue_detail_ics.htm?csnumber=64029&ICS1=35&ICS2=60|access-date=23 November 2018|archive-date=29 April 2016|archive-url=https://web.archive.org/web/20160429201210/http://www.iso.org/iso/home/store/catalogue_ics/catalogue_detail_ics.htm?csnumber=64029&ICS1=35&ICS2=60|url-status=live}}</ref> || [[C++14]], C++1y
|-
!scope="row"| 2017
| | ISO/IEC 14882:2017<ref name="isocpp2017">{{cite web|title=ISO/IEC 14882:2017|publisher=International Organization for Standardization|url=https://www.iso.org/standard/68564.html|access-date=2 December 2017|archive-date=17 May 2013|archive-url=https://www.webcitation.org/6GgR6NHSY?url=http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372|url-status=live}}</ref> || [[C++17]], C++1z
|-
!scope="row"| 2020
| | ISO/IEC 14882:2020<ref name="isocpp2020">{{cite web|title=ISO/IEC 14882:2020|publisher=International Organization for Standardization|url=https://www.iso.org/standard/79358.html|access-date=16 December 2020|archive-date=16 December 2020|archive-url=https://web.archive.org/web/20201216154357/https://www.iso.org/standard/79358.html|url-status=live}}</ref> || [[C++20]], C++2a
|}
Pada tahun 1998, C++ Standar Komite (ISO/IEC JTC1/SC22/WG21 Working Group) mengeluarkan Standar Internasional ISO/IEC 14882:1998 yang digunakan selama beberapa tahun. Pada tahun 2003 dirilis versi yang telah dikoreksi, ISO/IEC 14882:2003.
Pada tahun 2005, Laporan Teknis yang disebut "Laporan Teknis Perpustakaan 1" (sering dikenal sebagai TR1) dirilis. Revisi terbaru dari standar C++ adalah C+11 (sebelumnya dikenal C++0x) telah disetujui oleh ISO/IEC pada tanggal 12 Agustus 2011 dan telah diterbitkan sebagai 14882:11.
Sebagai bagian dari proses standarisasi, ISO juga menerbitkan laporan dan spesifikasi teknis:
* ISO/IEC TR 18015:2006<ref>{{cite web|title=ISO/IEC TR 18015:2006|url=https://www.iso.org/standard/43351.html|publisher=International Organization for Standardization|archive-url=https://web.archive.org/web/20190115203236/https://www.iso.org/standard/43351.html|archive-date=15 January 2019|access-date=15 February 2019|url-status=live}}</ref> dalam penggunaan dari C++ pada sistem tertanam dan implikasi performa bahasa C++ dan fitur perpustakaan.
* ISO/IEC TS 22277:2017<ref>{{cite web|title=ISO/IEC TS 22277:2017|url=https://www.iso.org/standard/73008.html|publisher=International Organization for Standardization|archive-url=https://web.archive.org/web/20190115202004/https://www.iso.org/standard/73008.html|archive-date=15 January 2019|access-date=15 February 2019|url-status=live}}</ref> pada coroutine, terintegrasi ke dalam [[C++20]]
* ISO/IEC TS 19216:2018<ref>{{cite web|title=ISO/IEC TS 19216:2018|url=https://www.iso.org/standard/64030.html|publisher=International Organization for Standardization|archive-url=https://web.archive.org/web/20190115201923/https://www.iso.org/standard/64030.html|archive-date=15 January 2019|access-date=15 February 2019|url-status=live}}</ref> pada pustaka jaringan
* ISO/IEC TS 21544:2018<ref>{{cite web|title=ISO/IEC TS 21544:2018|url=https://www.iso.org/standard/71051.html|publisher=International Organization for Standardization|archive-url=https://web.archive.org/web/20190115201858/https://www.iso.org/standard/71051.html|archive-date=15 January 2019|access-date=15 February 2019|url-status=live}}</ref> pada modul, terintegrasi ke dalam [[C++20]]
* ISO/IEC TS 19570:2018<ref>{{cite web|title=ISO/IEC TS 19570:2018|url=https://www.iso.org/standard/70588.html|publisher=International Organization for Standardization|archive-url=https://web.archive.org/web/20190115201519/https://www.iso.org/standard/70588.html|archive-date=15 January 2019|access-date=15 February 2019|url-status=live}}</ref> pada satu set ekstensi pustaka baru untuk paralelisme
* ISO/IEC TS 23619:2021<ref>{{cite web|title=ISO/IEC TS 23619:2021|url=https://www.iso.org/standard/76425.html|publisher=International Organization for Standardization|archive-url=https://web.archive.org/web/20181215153205/https://www.iso.org/standard/76425.html|archive-date=15 December 2018|access-date=11 October 2021|url-status=live}}</ref> pada ekstensi baru untuk refleksi
Lebih banyak spesifikasi teknis sedang dalam pengembangan dan menunggu persetujuan, termasuk set ekstensi konkurensi baru.<ref>See a list at {{cite web|title=Experimental C++ Features|url=https://en.cppreference.com/w/cpp/experimental|website=cppreference.com|archive-url=https://web.archive.org/web/20181123140131/https://en.cppreference.com/w/cpp/experimental|archive-date=23 November 2018|access-date=15 February 2019}}</ref>
== Contoh Program C++ ==
C++ mewarisi sebagian besar sintaks C. Berikut ini adalah program Hello world versi [[Bjarne Stroustrup]] yang menggunakan fasilitas stream [[pustaka dasar C++]] untuk menulis pesan ke [[Standard output#Standard output (stdout)|standard output]]:<ref>{{Cite book |first=Bjarne |last=Stroustrup |year=2000 |page=46 |title=The C++ Programming Language |edition=Special |publisher=Addison-Wesley |isbn=0-201-70073-5 }}</ref><ref>{{cite web |url=http://www.stroustrup.com/3rd_issues.html |title=Open issues for The C++ Programming Language (3rd Edition) |first=Bjarne |last=Stroustrup |postscript=. This code is copied directly from Bjarne Stroustrup's errata page (p. 633). He addresses the use of <code>'\n'</code> rather than <code>std::endl</code>. Also see [http://www.stroustrup.com/bs_faq2.html#void-main Can I write "void main()"?] for an explanation of the implicit <code>return 0;</code> in the <code>main</code> function. This implicit return is ''not'' available in other functions. |access-date=5 May 2014 |archive-date=5 May 2014 |archive-url=https://web.archive.org/web/20140505221112/http://www.stroustrup.com/3rd_issues.html |url-status=live }}</ref>
<!--
***************************************************************
*
* PLEASE NOTE:
*
* BEFORE MAKING CHANGES to the "Hello World" example
* please establish consensus by discussing your proposed changes
* on the Talk page. This is not the place to "Be Bold"; this
* has been discussed before at length.
*
* If you change the sample program without discussion, it will be
* reverted within a few minutes.
*
* The latest consensus is ''not'' to make any of those changes.
* This is the example "Hello, world!" by Bjarne Stroustrup,
* the author of the C++ language, and is used in
* his book, "The C++ Programming Language (3rd edition)".
*
***************************************************************
--><syntaxhighlight lang="cpp" line="1">
#include <iostream>
int main()
{
}
</syntaxhighlight><!--
*** PLEASE NOTE:****
* BEFORE MAKING CHANGES to the "Hello World" example
* please establish consensus by discussing your proposed changes
* on the Talk page. This is not the place to "Be Bold"; this
* has been discussed before.
*
* If you change the sample program without discussion, it will be
* reverted within a few minutes.
*
* The latest consensus is ''not'' to make any of those changes.
* This is the example "Hello, world!" by Bjarne Stroustrup,
* the author of the C++ language, and is used in
* his book, "The C++ Programming Language (3rd edition)".
*
*************************************************************** -->
=== Keterangan ===
Baris
Sebagai bagian dari proses kompilator, [[kompilator]] dari c++ menjalankan program yang dinamakan preprosesor.{{fact}} Preprosesor memiliki kemampuan menambahkan dan menghapus kode dari sumber. Pada bagian <code>#include</code> memberitahukan preprosesor untuk menyertakan kode dari iostream, berkas iostream berisi deklarasi untuk berbagai fungsi yang dibutuhkan oleh perangkat lunak, atau ''class-class'' yang dibutuhkan.<ref name="Nicolai"/>
Baris kedua: <syntaxhighlight lang="cpp">int main()</syntaxhighlight>
Pernyataan ini mendeklarasikan fungsi utama, bahwa suatu program C++ dapat berisi banyak fungsi, yang harus selalu memiliki sebuah fungsi utama (main function). Fungsi adalah modul yang berisi kode-kode untuk menyelesaikan masalah-masalah tertentu. Kata Void menandakan fungsi main tidak bertipe.<ref name="Nicolai"/>
Baris ketiga: <syntaxhighlight lang="cpp">{</syntaxhighlight>
Kurung kurawal buka menandakan awal program.<ref name="Nicolai"/>
Baris keempat
Cout adalah sebuah object dari [[
Baris kelima: <
Kurung kurawal tutup menandakan akhir program.<ref name="Nicolai2">{{cite book
== Kata yang dipesan ==
=== Kelompok pertama ===
C++ mempunyai 32 buah kata yang dipesan (''reserved words'')
{| class="wikitable"
Baris 62 ⟶ 171:
| const
| double
|
| int
| short
Baris 96 ⟶ 205:
|}
<ref name="Gregory">{{cite book
=== Kelompok kedua ===
Baris 144 ⟶ 253:
Kata-kata yang dipesan tersebut di atas tidak boleh dipakai sebagai nama variable, class, enum, macro, dan struct.<ref name="Gregory"/>
<syntaxhighlight lang="cpp">
# include <stdio.h>
int maksimum (int,int);
void tulis (int);
main()
int nilai 1,nilai 2,nilai maks;
printf (*\n ketikkan dua bilangan bulat:);
scanf("%d%d",& nilai 1,nilai 2);
nilai maks=maksimum (nilai 1,nilai 2);
tulis(nilai maks);
returns 0;
int maksimum(int x1,int x2)
if (x1>x2)
return x1;
else
return x2;
void tulis(int x)
printf("\n hasilnya adalah:%d",x);
</syntaxhighlight>
== Tipe data dasar ==
Untuk menyimpan suatu variabel diperlukan tempat khusus di dalam memori komputer
{| class="wikitable"
Baris 158 ⟶ 292:
| char
| Abjad/karakter atau untuk bilangan bulat kecil
| 1
| signed: -128 to 127
unsigned: 0 to 255
Baris 164 ⟶ 298:
| short int (short)
| Bilangan bulat dengan jangkauan pendek
| 2
| signed: -32768 to 32767
unsigned: 0 to 65535
Baris 170 ⟶ 304:
| int
| Bilangan bulat
| 4
| signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
Baris 176 ⟶ 310:
| long int (long)
| Integer dengan jangkauan panjang
| 4
| signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295
Baris 182 ⟶ 316:
| bool
| Boolean, dapat bernilai benar atau salah (true or false)
| i
| true or false
|-
| float
| Angka dengan titik mengambang (bilangan cacah)
| 4
| 3.4e +/- 38 (7 digit)
|-
| double
| Bilangan cacah dengan ketelitian ganda
| 8
| 1.7e +/- 308 (15 digits)
|-
| long double
| Bilangan cacah dengan ketelitian ganda panjang
| 8
| 1.7e +/- 308 (15 digits)
|-
| wchar_t
| Karakter lebar, biasa dipakai untuk Unicode karakter
| 2
| 1 karakter lebar
|}
==
* Acorn C/C++
* Borland C++
* C++/CX
* C++Builder
* Cfront
* Clang
* CodeWarrior
* Comeau C/C++
* ConceptGCC
* Digital Mars
*Dev-C++
*Eclipse IDE
* GNU Compiler Collection
* HP aC++
* IBM XL C++
* Intel C++ Compiler
* MinGW
*NetBeans IDE
* Norcroft C compiler
* Open64
* Oracle Solaris Studio
* PathScale
* The Portland Group
* ROSE (compiler framework)
* Shed Skin
* Sublime Text
* Softune
* TenDRA Compiler
* THINK C
* Turbo C++
* Visual C++
* IBM VisualAge
*Vim
* Watcom C/C++ compiler
* Zortech
== Keluarga bahasa pemrograman C++ ==
* Algorithmic skeleton
* C++/CLI
* C++/CX
* Charm++
* Embedded C++
* Felix (programming language)
* Intel Array Building Blocks
* Intel Parallel Studio
* Managed Extensions for C++
* R++
* Sieve C++ Parallel Programming System
* Threading Building Blocks
* ΜC++
== Lihat pula ==
* [[Dart (bahasa pemrograman)]]
* [[C Sharp (bahasa pemrograman)|C#]]
* [[Carbon (bahasa pemrograman)]]
* [[Rust (bahasa pemrograman)|Rust]]
== Referensi ==
{{reflist}}
== Bacaan lanjutan ==
{{Refbegin|30em}}
* {{Cite book|last1=Abrahams|first1=David|last2=Gurtovoy|first2=Aleksey|year=2005|title=C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond|url=https://archive.org/details/ctemplatemetapro0000abra|publisher=Addison-Wesley|isbn=0-321-22725-5|author-link=David Abrahams (computer programmer)}}
* {{Cite book|last=Alexandrescu|first=Andrei|year=2001|title=Modern C++ Design: Generic Programming and Design Patterns Applied|url=https://archive.org/details/moderncdesigngen0000alex|publisher=Addison-Wesley|isbn=0-201-70431-5|author-link=Andrei Alexandrescu}}
* {{Cite book|last1=Alexandrescu|first1=Andrei|last2=Sutter|first2=Herb|year=2004|title=C++ Design and Coding Standards: Rules and Guidelines for Writing Programs|url=https://archive.org/details/ccodingstandards0000sutt|publisher=Addison-Wesley|isbn=0-321-11358-6|author-link=Andrei Alexandrescu|author-link2=Herb Sutter}}
* {{Cite book|last=Becker|first=Pete|year=2006|title=The C++ Standard Library Extensions : A Tutorial and Reference|url=https://archive.org/details/cstandardlibrary0000beck|publisher=Addison-Wesley|isbn=0-321-41299-0|author-link=Pete Becker}}
* {{Cite book|last=Brokken|first=Frank|year=2010|url=http://www.icce.rug.nl/documents/cplusplus/|title=C++ Annotations|publisher=University of Groningen|isbn=978-90-367-0470-0|access-date=28 April 2010|archive-url=https://web.archive.org/web/20100428014354/http://www.icce.rug.nl/documents/cplusplus/|archive-date=28 April 2010|url-status=live}}
* {{Cite book|last=Coplien|first=James O.|date=1994|url=https://archive.org/details/advancedcbsprogr00copl|title=Advanced C++: Programming Styles and Idioms|isbn=0-201-54855-0|author-link=James O. Coplien|orig-year=reprinted with corrections, original year of publication 1992}}
* {{Cite book|last=Dewhurst|first=Stephen C.|year=2005|title=C++ Common Knowledge: Essential Intermediate Programming|url=https://archive.org/details/ccommonknowledge0000dewh|publisher=Addison-Wesley|isbn=0-321-32192-8}}
* {{Cite book|author=Information Technology Industry Council|date=15 October 2003|title=Programming languages – C++|location=Geneva|publisher=ISO/IEC|edition=Second|id=14882:2003(E)|author-link=Information and Communications Technology Council}}
* {{Cite book|last=Josuttis|first=Nicolai M.|year=2012|title=The C++ Standard Library, A Tutorial and Reference|publisher=Addison-Wesley|isbn=978-0-321-62321-8|edition=Second}}
* {{Cite book|last1=Koenig|first1=Andrew|last2=Moo|first2=Barbara E.|year=2000|url=https://archive.org/details/acceleratedcprac2000koen|title=Accelerated C++ – Practical Programming by Example|publisher=Addison-Wesley|isbn=0-201-70353-X|author-link=Andrew Koenig (programmer)}}
* {{Cite book|last1=Lippman|first1=Stanley B.|last2=Lajoie|first2=Josée|last3=Moo|first3=Barbara E.|year=2011|url=https://archive.org/details/cprimer0000lipp_5thed|title=C++ Primer|publisher=Addison-Wesley|isbn=978-0-321-71411-4|edition=Fifth|author-link=Stanley B. Lippman|url-access=registration}}
* {{Cite book|last=Lippman|first=Stanley B.|year=1996|title=Inside the C++ Object Model|url=https://archive.org/details/insidecobjectmod0000lipp|publisher=Addison-Wesley|isbn=0-201-83454-5}}
* {{Cite book|last=Meyers|first=Scott|year=2005|url=https://archive.org/details/effectivec55spec00meye|title=Effective C++|publisher=Addison-Wesley|isbn=0-321-33487-6|edition=Third|author-link=Scott Meyers}}
* {{Cite book|last=Stroustrup|first=Bjarne|year=2013|title=[[The C++ Programming Language]]|publisher=Addison-Wesley|isbn=978-0-321-56384-2|edition=Fourth|author-link=Bjarne Stroustrup}}
* {{Cite book|last=Stroustrup|first=Bjarne|year=1994|title=[[The Design and Evolution of C++]]|publisher=Addison-Wesley|isbn=0-201-54330-3|author-link=Bjarne Stroustrup}}
* {{Cite book|last=Stroustrup|first=Bjarne|year=2014|title=Programming: Principles and Practice Using C++|url=https://archive.org/details/programmingprinc0000stro_b7o6|publisher=Addison-Wesley|isbn=978-0-321-99278-9|edition=Second|author-link=Bjarne Stroustrup}}
* {{Cite book|last=Sutter|first=Herb|year=2001|title=More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions|url=https://archive.org/details/moreexceptionalc0000sutt|publisher=Addison-Wesley|isbn=0-201-70434-X|author-link=Herb Sutter}}
* {{Cite book|last=Sutter|first=Herb|year=2004|title=Exceptional C++ Style|publisher=Addison-Wesley|isbn=0-201-76042-8|author-link=Herb Sutter}}
* {{Cite book|last1=Vandevoorde|first1=David|last2=Josuttis|first2=Nicolai M.|year=2003|title=C++ Templates: The complete Guide|url=https://archive.org/details/ctemplatescomple0000vand|publisher=Addison-Wesley|isbn=0-201-73484-2}}
{{refend}}
== Pranala luar ==
* [http://www.cuj.com C++ Users Journal]
* [http://www.sgi.com/tech/stl/ Standard Template Library]
* [http://erdani.org/ Andrei Alexandrescu]
* [http://www.codeguru.com/ Code guru, C++ resource]
* [
* http://www.cplusplus.com/
* http://www.cplusplus.com/doc/tutorial/
* http://www.cplusplus.com/doc/tutorial/program_structure/
* http://www.learncpp.com/
* http://www.cprogramming.com/
* http://en.cppreference.com/w/
* http://www.cs.cf.ac.uk/Dave/C/node3.html
* https://goonlinetools.com/cpp-compiler/
* http://www.thefreecountry.com/compilers/cpp.shtml
* http://www.compilers.net/dir/free/compilers/ccpp.htm {{Webarchive|url=https://web.archive.org/web/20141013143049/http://www.compilers.net/Dir/Free/Compilers/CCpp.htm |date=2014-10-13 }}
* http://www.cppgameprogramming.com/
* http://www.cprogramming.com/game-programming.html
{{Daftar bahasa pemrograman}}
{{Authority control}}
[[Kategori:C++| ]]
[[Kategori:Bahasa pemrograman]]
[[Kategori:
[[Kategori:
[[Kategori:Bahasa pemrograman tingkat tinggi]]
[[Kategori:Bahasa pemrograman yang dibuat pada tahun 1983]]
|